summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-02-04 13:50:51 -0800
committerGitHub <noreply@github.com>2021-02-04 13:50:51 -0800
commitc40f10b704b8bd5a744cc9b3964344585436b1ac (patch)
tree1c9608f3cc32949d88fe04f3512cd3147fc3fe1f /source
parent7f266f1ea7a51213069282296a905650fd405c3f (diff)
[gfx] Shader-object driven shader compilation. (#1688)
Diffstat (limited to 'source')
-rw-r--r--source/core/slang-dictionary.h17
-rw-r--r--source/core/slang-short-list.h7
-rw-r--r--source/core/slang-smart-pointer.h6
-rwxr-xr-xsource/slang/slang-compiler.h11
4 files changed, 25 insertions, 16 deletions
diff --git a/source/core/slang-dictionary.h b/source/core/slang-dictionary.h
index 4c352d55b..51b61de60 100644
--- a/source/core/slang-dictionary.h
+++ b/source/core/slang-dictionary.h
@@ -135,15 +135,17 @@ namespace Slang
}
};
- inline int GetHashPos(TKey& key) const
+ template<typename KeyType>
+ inline int GetHashPos(KeyType& key) const
{
SLANG_ASSERT(bucketSizeMinusOne > 0);
const unsigned int hash = (unsigned int)getHashCode(key);
return (hash * 2654435761u) % (unsigned int)(bucketSizeMinusOne);
}
- FindPositionResult FindPosition(const TKey& key) const
+ template<typename KeyType>
+ FindPositionResult FindPosition(const KeyType& key) const
{
- int hashPos = GetHashPos(const_cast<TKey&>(key));
+ int hashPos = GetHashPos(const_cast<KeyType&>(key));
int insertPos = -1;
int numProbes = 0;
while (numProbes <= bucketSizeMinusOne)
@@ -380,14 +382,16 @@ namespace Slang
throw InvalidOperationException("Inconsistent find result returned. This is a bug in Dictionary implementation.");
}
- bool ContainsKey(const TKey& key) const
+ template<typename KeyType>
+ bool ContainsKey(const KeyType& key) const
{
if (bucketSizeMinusOne == -1)
return false;
auto pos = FindPosition(key);
return pos.ObjectPosition != -1;
}
- bool TryGetValue(const TKey& key, TValue& value) const
+ template<typename KeyType>
+ bool TryGetValue(const KeyType& key, TValue& value) const
{
if (bucketSizeMinusOne == -1)
return false;
@@ -399,7 +403,8 @@ namespace Slang
}
return false;
}
- TValue* TryGetValue(const TKey& key) const
+ template<typename KeyType>
+ TValue* TryGetValue(const KeyType& key) const
{
if (bucketSizeMinusOne == -1)
return nullptr;
diff --git a/source/core/slang-short-list.h b/source/core/slang-short-list.h
index 82ad4fe1e..7d51a8abf 100644
--- a/source/core/slang-short-list.h
+++ b/source/core/slang-short-list.h
@@ -47,6 +47,13 @@ namespace Slang
return *this;
}
+ ThisType& operator=(const ThisType& other)
+ {
+ clearAndDeallocate();
+ addRange(other);
+ return *this;
+ }
+
ThisType& operator=(ThisType&& list)
{
// Could just do a swap here, and memory would be freed on rhs dtor
diff --git a/source/core/slang-smart-pointer.h b/source/core/slang-smart-pointer.h
index 53ac010ed..eb9fe7be5 100644
--- a/source/core/slang-smart-pointer.h
+++ b/source/core/slang-smart-pointer.h
@@ -114,9 +114,9 @@ namespace Slang
template <typename U>
RefPtr(RefPtr<U> const& p,
typename EnableIf<IsConvertible<T*, U*>::Value, void>::type * = 0)
- : pointer((U*) p)
+ : pointer(static_cast<U*>(p))
{
- addReference((U*) p);
+ addReference(static_cast<U*>(p));
}
#if 0
@@ -200,7 +200,7 @@ namespace Slang
~RefPtr()
{
- releaseReference((Slang::RefObject*) pointer);
+ releaseReference(static_cast<Slang::RefObject*>(pointer));
}
T& operator*() const
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index ac2d72862..90b1e30f3 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -318,9 +318,6 @@ namespace Slang
/// Get one of the global shader parametesr linked into this component type.
virtual ShaderParamInfo getShaderParam(Index index) = 0;
- /// Get the number of (unspecialized) specialization parameters for the component type.
- virtual Index getSpecializationParamCount() = 0;
-
/// Get the specialization parameter at `index`.
virtual SpecializationParam const& getSpecializationParam(Index index) = 0;
@@ -511,7 +508,7 @@ namespace Slang
Index getShaderParamCount() SLANG_OVERRIDE;
ShaderParamInfo getShaderParam(Index index) SLANG_OVERRIDE;
- Index getSpecializationParamCount() SLANG_OVERRIDE;
+ SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE;
SpecializationParam const& getSpecializationParam(Index index) SLANG_OVERRIDE;
Index getRequirementCount() SLANG_OVERRIDE;
@@ -598,7 +595,7 @@ namespace Slang
Index getShaderParamCount() SLANG_OVERRIDE { return m_base->getShaderParamCount(); }
ShaderParamInfo getShaderParam(Index index) SLANG_OVERRIDE { return m_base->getShaderParam(index); }
- Index getSpecializationParamCount() SLANG_OVERRIDE { return 0; }
+ SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE { return 0; }
SpecializationParam const& getSpecializationParam(Index index) SLANG_OVERRIDE { SLANG_UNUSED(index); static SpecializationParam dummy; return dummy; }
Index getRequirementCount() SLANG_OVERRIDE;
@@ -759,7 +756,7 @@ namespace Slang
String mangledName);
/// Get the number of existential type parameters for the entry point.
- Index getSpecializationParamCount() SLANG_OVERRIDE;
+ SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE;
/// Get the existential type parameter at `index`.
SpecializationParam const& getSpecializationParam(Index index) SLANG_OVERRIDE;
@@ -969,7 +966,7 @@ namespace Slang
Index getShaderParamCount() SLANG_OVERRIDE { return m_shaderParams.getCount(); }
ShaderParamInfo getShaderParam(Index index) SLANG_OVERRIDE { return m_shaderParams[index]; }
- Index getSpecializationParamCount() SLANG_OVERRIDE { return m_specializationParams.getCount(); }
+ SLANG_NO_THROW Index SLANG_MCALL getSpecializationParamCount() SLANG_OVERRIDE { return m_specializationParams.getCount(); }
SpecializationParam const& getSpecializationParam(Index index) SLANG_OVERRIDE { return m_specializationParams[index]; }
Index getRequirementCount() SLANG_OVERRIDE;