diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-08-24 13:09:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-24 10:09:07 -0700 |
| commit | 0b808453407f8feef8574cae99afd90771712185 (patch) | |
| tree | 01698f8a4354d836205731762619e5b4205d31e7 /source/slang/slang-reflection-api.cpp | |
| parent | f5755019246504ad4da4614d1e34a00d74970ea7 (diff) | |
Use enums with backing types in Slang API (#2375)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Use enum types and specify backing rather than use typedefs so as to get enum type safety.
* Add version of TextureFlavor that uses internal types.
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-reflection-api.cpp')
| -rw-r--r-- | source/slang/slang-reflection-api.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp index 96b1f9004..ae43f9113 100644 --- a/source/slang/slang-reflection-api.cpp +++ b/source/slang/slang-reflection-api.cpp @@ -542,7 +542,7 @@ SLANG_API unsigned int spReflectionType_GetColumnCount(SlangReflectionType* inTy SLANG_API SlangScalarType spReflectionType_GetScalarType(SlangReflectionType* inType) { auto type = convert(inType); - if(!type) return 0; + if(!type) return SLANG_SCALAR_TYPE_NONE; if(auto matrixType = as<MatrixExpressionType>(type)) { @@ -623,7 +623,7 @@ SLANG_API SlangReflectionUserAttribute* spReflectionType_FindUserAttributeByName SLANG_API SlangResourceShape spReflectionType_GetResourceShape(SlangReflectionType* inType) { auto type = convert(inType); - if(!type) return 0; + if(!type) return SLANG_RESOURCE_NONE; while(auto arrayType = as<ArrayExpressionType>(type)) { @@ -659,7 +659,7 @@ SLANG_API SlangResourceShape spReflectionType_GetResourceShape(SlangReflectionTy SLANG_API SlangResourceAccess spReflectionType_GetResourceAccess(SlangReflectionType* inType) { auto type = convert(inType); - if(!type) return 0; + if(!type) return SLANG_RESOURCE_ACCESS_NONE; while(auto arrayType = as<ArrayExpressionType>(type)) { @@ -1038,7 +1038,7 @@ SLANG_API SlangParameterCategory spReflectionTypeLayout_GetCategoryByIndex(Slang auto typeLayout = convert(inTypeLayout); if(!typeLayout) return SLANG_PARAMETER_CATEGORY_NONE; - return typeLayout->resourceInfos[index].kind; + return SlangParameterCategory(typeLayout->resourceInfos[index].kind); } SLANG_API SlangMatrixLayoutMode spReflectionTypeLayout_GetMatrixLayoutMode(SlangReflectionTypeLayout* inTypeLayout) @@ -1048,7 +1048,7 @@ SLANG_API SlangMatrixLayoutMode spReflectionTypeLayout_GetMatrixLayoutMode(Slang if( auto matrixLayout = as<MatrixTypeLayout>(typeLayout) ) { - return matrixLayout->mode; + return SlangMatrixLayoutMode(matrixLayout->mode); } else { @@ -1248,10 +1248,10 @@ namespace Slang switch( shape ) { default: - return SLANG_BINDING_TYPE_TEXTURE | mutableFlag; + return SlangBindingType(SLANG_BINDING_TYPE_TEXTURE | mutableFlag); case SLANG_TEXTURE_BUFFER: - return SLANG_BINDING_TYPE_TYPED_BUFFER | mutableFlag; + return SlangBindingType(SLANG_BINDING_TYPE_TYPED_BUFFER | mutableFlag); } } else if( auto structuredBufferType = as<HLSLStructuredBufferTypeBase>(type) ) @@ -1968,8 +1968,8 @@ SLANG_API SlangBindingType spReflectionTypeLayout_getBindingRangeType(SlangRefle if(!typeLayout) return SLANG_BINDING_TYPE_UNKNOWN; auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - if(index < 0) return 0; - if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; + if(index < 0) return SLANG_BINDING_TYPE_UNKNOWN; + if(index >= extTypeLayout->m_bindingRanges.getCount()) return SLANG_BINDING_TYPE_UNKNOWN; auto& bindingRange = extTypeLayout->m_bindingRanges[index]; return bindingRange.bindingType; @@ -2155,16 +2155,16 @@ SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetDescriptorRangeDescrip SLANG_API SlangBindingType spReflectionTypeLayout_getDescriptorSetDescriptorRangeType(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) { auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; + if(!typeLayout) return SLANG_BINDING_TYPE_UNKNOWN; auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - if(setIndex < 0) return 0; - if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; + if(setIndex < 0) return SLANG_BINDING_TYPE_UNKNOWN; + if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return SLANG_BINDING_TYPE_UNKNOWN; auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; - if(rangeIndex < 0) return 0; - if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; + if(rangeIndex < 0) return SLANG_BINDING_TYPE_UNKNOWN; + if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return SLANG_BINDING_TYPE_UNKNOWN; auto& range = descriptorSet->descriptorRanges[rangeIndex]; return range.bindingType; @@ -2173,16 +2173,16 @@ SLANG_API SlangBindingType spReflectionTypeLayout_getDescriptorSetDescriptorRang SLANG_API SlangParameterCategory spReflectionTypeLayout_getDescriptorSetDescriptorRangeCategory(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) { auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; + if(!typeLayout) return SLANG_PARAMETER_CATEGORY_NONE; auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - if(setIndex < 0) return 0; - if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; + if(setIndex < 0) return SLANG_PARAMETER_CATEGORY_NONE; + if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return SLANG_PARAMETER_CATEGORY_NONE; auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; - if(rangeIndex < 0) return 0; - if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; + if(rangeIndex < 0) return SLANG_PARAMETER_CATEGORY_NONE; + if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return SLANG_PARAMETER_CATEGORY_NONE; auto& range = descriptorSet->descriptorRanges[rangeIndex]; return SlangParameterCategory(range.kind); |
