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 | |
| 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>
| -rw-r--r-- | slang.h | 105 | ||||
| -rw-r--r-- | source/slang/slang-compiler.cpp | 2 | ||||
| -rwxr-xr-x | source/slang/slang-compiler.h | 20 | ||||
| -rw-r--r-- | source/slang/slang-options.cpp | 8 | ||||
| -rw-r--r-- | source/slang/slang-profile.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-reflection-api.cpp | 38 | ||||
| -rw-r--r-- | source/slang/slang-repro.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang-type-system-shared.h | 8 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 2 | ||||
| -rw-r--r-- | tools/slang-reflection-test/slang-reflection-test-main.cpp | 7 | ||||
| -rw-r--r-- | tools/slang-test/slangc-tool.cpp | 3 | ||||
| -rw-r--r-- | tools/test-server/test-server-main.cpp | 3 |
12 files changed, 104 insertions, 96 deletions
@@ -518,8 +518,8 @@ extern "C" conditions, and all values >= SLANG_SEVERITY_ERROR indicating compilation failure. */ - typedef int SlangSeverity; - enum + typedef int SlangSeverityIntegral; + enum SlangSeverity : SlangSeverityIntegral { SLANG_SEVERITY_DISABLED = 0, /**< A message that is disabled, filtered out. */ SLANG_SEVERITY_NOTE, /**< An informative message. */ @@ -536,8 +536,8 @@ extern "C" SLANG_DIAGNOSTIC_FLAG_TREAT_WARNINGS_AS_ERRORS = 0x02 }; - typedef int SlangBindableResourceType; - enum + typedef int SlangBindableResourceIntegral; + enum SlangBindableResourceType : SlangBindableResourceIntegral { SLANG_NON_BINDABLE = 0, SLANG_TEXTURE, @@ -546,8 +546,8 @@ extern "C" SLANG_STORAGE_BUFFER, }; - typedef int SlangCompileTarget; - enum + typedef int SlangCompileTargetIntegral; + enum SlangCompileTarget : SlangCompileTargetIntegral { SLANG_TARGET_UNKNOWN, SLANG_TARGET_NONE, @@ -577,8 +577,8 @@ extern "C" /* A "container format" describes the way that the outputs for multiple files, entry points, targets, etc. should be combined into a single artifact for output. */ - typedef int SlangContainerFormat; - enum + typedef int SlangContainerFormatIntegral; + enum SlangContainerFormat : SlangContainerFormatIntegral { /* Don't generate a container. */ SLANG_CONTAINER_FORMAT_NONE, @@ -641,7 +641,7 @@ extern "C" /*! @brief Flags to control code generation behavior of a compilation target */ typedef unsigned int SlangTargetFlags; - enum + enum { /* When compiling for a D3D Shader Model 5.1 or higher target, allocate distinct register spaces for parameter blocks. @@ -666,8 +666,8 @@ extern "C" /*! @brief Options to control floating-point precision guarantees for a target. */ - typedef unsigned int SlangFloatingPointMode; - enum + typedef unsigned int SlangFloatingPointModeIntegral; + enum SlangFloatingPointMode : SlangFloatingPointModeIntegral { SLANG_FLOATING_POINT_MODE_DEFAULT = 0, SLANG_FLOATING_POINT_MODE_FAST, @@ -677,8 +677,8 @@ extern "C" /*! @brief Options to control emission of `#line` directives */ - typedef unsigned int SlangLineDirectiveMode; - enum + typedef unsigned int SlangLineDirectiveModeIntegral; + enum SlangLineDirectiveMode : SlangLineDirectiveModeIntegral { SLANG_LINE_DIRECTIVE_MODE_DEFAULT = 0, /**< Default behavior: pick behavior base on target. */ SLANG_LINE_DIRECTIVE_MODE_NONE, /**< Don't emit line directives at all. */ @@ -699,28 +699,29 @@ extern "C" SLANG_SOURCE_LANGUAGE_COUNT_OF, }; - typedef unsigned int SlangProfileID; - enum + typedef unsigned int SlangProfileIDIntegral; + enum SlangProfileID : SlangProfileIDIntegral { SLANG_PROFILE_UNKNOWN, }; - typedef SlangInt32 SlangCapabilityID; - enum + + typedef SlangInt32 SlangCapabilityIDIntegral; + enum SlangCapabilityID : SlangCapabilityIDIntegral { SLANG_CAPABILITY_UNKNOWN = 0, }; - typedef unsigned int SlangMatrixLayoutMode; - enum + typedef unsigned int SlangMatrixLayoutModeIntegral; + enum SlangMatrixLayoutMode : SlangMatrixLayoutModeIntegral { SLANG_MATRIX_LAYOUT_MODE_UNKNOWN = 0, SLANG_MATRIX_LAYOUT_ROW_MAJOR, SLANG_MATRIX_LAYOUT_COLUMN_MAJOR, }; - typedef SlangUInt32 SlangStage; - enum + typedef SlangUInt32 SlangStageIntegral; + enum SlangStage : SlangStageIntegral { SLANG_STAGE_NONE, SLANG_STAGE_VERTEX, @@ -742,8 +743,8 @@ extern "C" SLANG_STAGE_PIXEL = SLANG_STAGE_FRAGMENT, }; - typedef SlangUInt32 SlangDebugInfoLevel; - enum + typedef SlangUInt32 SlangDebugInfoLevelIntegral; + enum SlangDebugInfoLevel : SlangDebugInfoLevelIntegral { SLANG_DEBUG_INFO_LEVEL_NONE = 0, /**< Don't emit debug information at all. */ SLANG_DEBUG_INFO_LEVEL_MINIMAL, /**< Emit as little debug information as possible, while still supporting stack trackes. */ @@ -752,8 +753,8 @@ extern "C" }; - typedef SlangUInt32 SlangOptimizationLevel; - enum + typedef SlangUInt32 SlangOptimizationLevelIntegral; + enum SlangOptimizationLevel : SlangOptimizationLevelIntegral { SLANG_OPTIMIZATION_LEVEL_NONE = 0, /**< Don't optimize at all. */ SLANG_OPTIMIZATION_LEVEL_DEFAULT, /**< Default optimization level: balance code quality and compilation time. */ @@ -1064,8 +1065,8 @@ extern "C" #define SLANG_UUID_ISlangSharedLibraryLoader ISlangSharedLibraryLoader::getTypeGuid() /* Type that identifies how a path should be interpreted */ - typedef unsigned int SlangPathType; - enum + typedef unsigned int SlangPathTypeIntegral; + enum SlangPathType : SlangPathTypeIntegral { SLANG_PATH_TYPE_DIRECTORY, /**< Path specified specifies a directory. */ SLANG_PATH_TYPE_FILE, /**< Path specified is to a file. */ @@ -1233,8 +1234,8 @@ extern "C" #define SLANG_UUID_ISlangMutableFileSystem ISlangMutableFileSystem::getTypeGuid() /* Identifies different types of writer target*/ - typedef unsigned int SlangWriterChannel; - enum + typedef unsigned int SlangWriterChannelIntegral; + enum SlangWriterChannel : SlangWriterChannelIntegral { SLANG_WRITER_CHANNEL_DIAGNOSTIC, SLANG_WRITER_CHANNEL_STD_OUTPUT, @@ -1242,8 +1243,8 @@ extern "C" SLANG_WRITER_CHANNEL_COUNT_OF, }; - typedef unsigned int SlangWriterMode; - enum + typedef unsigned int SlangWriterModeIntegral; + enum SlangWriterMode : SlangWriterModeIntegral { SLANG_WRITER_MODE_TEXT, SLANG_WRITER_MODE_BINARY, @@ -1797,8 +1798,8 @@ extern "C" // type reflection - typedef unsigned int SlangTypeKind; - enum + typedef unsigned int SlangTypeKindIntegral; + enum SlangTypeKind : SlangTypeKindIntegral { SLANG_TYPE_KIND_NONE, SLANG_TYPE_KIND_STRUCT, @@ -1820,8 +1821,8 @@ extern "C" SLANG_TYPE_KIND_COUNT, }; - typedef unsigned int SlangScalarType; - enum + typedef unsigned int SlangScalarTypeIntegral; + enum SlangScalarType : SlangScalarTypeIntegral { SLANG_SCALAR_TYPE_NONE, SLANG_SCALAR_TYPE_VOID, @@ -1841,8 +1842,8 @@ extern "C" #ifndef SLANG_RESOURCE_SHAPE # define SLANG_RESOURCE_SHAPE - typedef unsigned int SlangResourceShape; - enum + typedef unsigned int SlangResourceShapeIntegral; + enum SlangResourceShape : SlangResourceShapeIntegral { SLANG_RESOURCE_BASE_SHAPE_MASK = 0x0F, @@ -1873,8 +1874,8 @@ extern "C" SLANG_TEXTURE_2D_MULTISAMPLE_ARRAY = SLANG_TEXTURE_2D | SLANG_TEXTURE_MULTISAMPLE_FLAG | SLANG_TEXTURE_ARRAY_FLAG, }; #endif - typedef unsigned int SlangResourceAccess; - enum + typedef unsigned int SlangResourceAccessIntegral; + enum SlangResourceAccess : SlangResourceAccessIntegral { SLANG_RESOURCE_ACCESS_NONE, SLANG_RESOURCE_ACCESS_READ, @@ -1885,8 +1886,8 @@ extern "C" SLANG_RESOURCE_ACCESS_WRITE, }; - typedef unsigned int SlangParameterCategory; - enum + typedef unsigned int SlangParameterCategoryIntegral; + enum SlangParameterCategory : SlangParameterCategoryIntegral { SLANG_PARAMETER_CATEGORY_NONE, SLANG_PARAMETER_CATEGORY_MIXED, @@ -1983,8 +1984,8 @@ extern "C" When you wnat to answer "what type of descriptor range should this parameter use?" you should use `SlangBindingType`. */ - typedef SlangUInt32 SlangBindingType; - enum + typedef SlangUInt32 SlangBindingTypeIntegral; + enum SlangBindingType : SlangBindingTypeIntegral { SLANG_BINDING_TYPE_UNKNOWN = 0, @@ -2015,14 +2016,14 @@ extern "C" SLANG_BINDING_TYPE_EXT_MASK = 0xFF00, }; - typedef SlangUInt32 SlangLayoutRules; - enum + typedef SlangUInt32 SlangLayoutRulesIntegral; + enum SlangLayoutRules : SlangLayoutRulesIntegral { SLANG_LAYOUT_RULES_DEFAULT, }; - typedef SlangUInt32 SlangModifierID; - enum + typedef SlangUInt32 SlangModifierIDIntegral; + enum SlangModifierID : SlangModifierIDIntegral { SLANG_MODIFIER_SHARED, }; @@ -2347,7 +2348,7 @@ namespace slang Feedback = SLANG_TYPE_KIND_FEEDBACK, }; - enum ScalarType : SlangScalarType + enum ScalarType : SlangScalarTypeIntegral { None = SLANG_SCALAR_TYPE_NONE, Void = SLANG_SCALAR_TYPE_VOID, @@ -2468,7 +2469,7 @@ namespace slang } }; - enum ParameterCategory : SlangParameterCategory + enum ParameterCategory : SlangParameterCategoryIntegral { // TODO: these aren't scoped... None = SLANG_PARAMETER_CATEGORY_NONE, @@ -2500,7 +2501,7 @@ namespace slang FragmentOutput = SLANG_PARAMETER_CATEGORY_FRAGMENT_OUTPUT, }; - enum class BindingType : SlangBindingType + enum class BindingType : SlangBindingTypeIntegral { Unknown = SLANG_BINDING_TYPE_UNKNOWN, @@ -2847,7 +2848,7 @@ namespace slang struct Modifier { - enum ID : SlangModifierID + enum ID : SlangModifierIDIntegral { Shared = SLANG_MODIFIER_SHARED, }; @@ -3049,7 +3050,7 @@ namespace slang } }; - enum class LayoutRules : SlangLayoutRules + enum class LayoutRules : SlangLayoutRulesIntegral { Default = SLANG_LAYOUT_RULES_DEFAULT, }; diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index d50350b29..c1f25a012 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -1221,7 +1221,7 @@ namespace Slang } // Set the matrix layout - options.matrixLayout = getTargetReq()->getDefaultMatrixLayoutMode(); + options.matrixLayout = SlangMatrixLayoutMode(getTargetReq()->getDefaultMatrixLayoutMode()); } // Set the profile diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 0dbaa9099..3c17d1c09 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -49,7 +49,7 @@ namespace Slang GenerateChoice }; - enum class StageTarget + enum class StageTarget { Unknown, VertexShader, @@ -60,7 +60,7 @@ namespace Slang ComputeShader, }; - enum class CodeGenTarget + enum class CodeGenTarget : SlangCompileTargetIntegral { Unknown = SLANG_TARGET_UNKNOWN, None = SLANG_TARGET_NONE, @@ -91,13 +91,13 @@ namespace Slang void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val); - enum class ContainerFormat : SlangContainerFormat + enum class ContainerFormat : SlangContainerFormatIntegral { None = SLANG_CONTAINER_FORMAT_NONE, SlangModule = SLANG_CONTAINER_FORMAT_SLANG_MODULE, }; - enum class LineDirectiveMode : SlangLineDirectiveMode + enum class LineDirectiveMode : SlangLineDirectiveModeIntegral { Default = SLANG_LINE_DIRECTIVE_MODE_DEFAULT, None = SLANG_LINE_DIRECTIVE_MODE_NONE, @@ -117,13 +117,13 @@ namespace Slang // laid out with row-major or column-major // storage. // - enum MatrixLayoutMode + enum MatrixLayoutMode : SlangMatrixLayoutModeIntegral { kMatrixLayoutMode_RowMajor = SLANG_MATRIX_LAYOUT_ROW_MAJOR, kMatrixLayoutMode_ColumnMajor = SLANG_MATRIX_LAYOUT_COLUMN_MAJOR, }; - enum class DebugInfoLevel : SlangDebugInfoLevel + enum class DebugInfoLevel : SlangDebugInfoLevelIntegral { None = SLANG_DEBUG_INFO_LEVEL_NONE, Minimal = SLANG_DEBUG_INFO_LEVEL_MINIMAL, @@ -131,7 +131,7 @@ namespace Slang Maximal = SLANG_DEBUG_INFO_LEVEL_MAXIMAL, }; - enum class OptimizationLevel : SlangOptimizationLevel + enum class OptimizationLevel : SlangOptimizationLevelIntegral { None = SLANG_OPTIMIZATION_LEVEL_NONE, Default = SLANG_OPTIMIZATION_LEVEL_DEFAULT, @@ -1416,14 +1416,14 @@ namespace Slang SourceManager* getSourceManager(); }; - enum class FloatingPointMode : SlangFloatingPointMode + enum class FloatingPointMode : SlangFloatingPointModeIntegral { Default = SLANG_FLOATING_POINT_MODE_DEFAULT, Fast = SLANG_FLOATING_POINT_MODE_FAST, Precise = SLANG_FLOATING_POINT_MODE_PRECISE, }; - enum class WriterChannel : SlangWriterChannel + enum class WriterChannel : SlangWriterChannelIntegral { Diagnostic = SLANG_WRITER_CHANNEL_DIAGNOSTIC, StdOutput = SLANG_WRITER_CHANNEL_STD_OUTPUT, @@ -1431,7 +1431,7 @@ namespace Slang CountOf = SLANG_WRITER_CHANNEL_COUNT_OF, }; - enum class WriterMode : SlangWriterMode + enum class WriterMode : SlangWriterModeIntegral { Text = SLANG_WRITER_MODE_TEXT, Binary = SLANG_WRITER_MODE_BINARY, diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index a28217fd8..f88f02221 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -1126,7 +1126,7 @@ struct OptionsParser // UnownedStringSlice profileName = sliceCount >= 1 ? slices[0] : UnownedTerminatedStringSlice(""); - SlangProfileID profileID = Slang::Profile::lookUp(profileName).raw; + SlangProfileID profileID = SlangProfileID(Slang::Profile::lookUp(profileName).raw); if( profileID == SLANG_PROFILE_UNKNOWN ) { sink->diagnose(operand.loc, Diagnostics::unknownProfile, profileName); @@ -1332,11 +1332,11 @@ struct OptionsParser } else if(argValue == "-matrix-layout-row-major") { - defaultMatrixLayoutMode = kMatrixLayoutMode_RowMajor; + defaultMatrixLayoutMode = SlangMatrixLayoutMode(kMatrixLayoutMode_RowMajor); } else if(argValue == "-matrix-layout-column-major") { - defaultMatrixLayoutMode = kMatrixLayoutMode_ColumnMajor; + defaultMatrixLayoutMode = SlangMatrixLayoutMode(kMatrixLayoutMode_ColumnMajor); } else if(argValue == "-line-directive-mode") { @@ -1993,7 +1993,7 @@ struct OptionsParser if( rawTarget.profileVersion != ProfileVersion::Unknown ) { - compileRequest->setTargetProfile(targetID, Profile(rawTarget.profileVersion).raw); + compileRequest->setTargetProfile(targetID, SlangProfileID(Profile(rawTarget.profileVersion).raw)); } for( auto atom : rawTarget.capabilityAtoms ) { diff --git a/source/slang/slang-profile.h b/source/slang/slang-profile.h index 5150da27a..661274ad4 100644 --- a/source/slang/slang-profile.h +++ b/source/slang/slang-profile.h @@ -44,7 +44,7 @@ namespace Slang void printDiagnosticArg(StringBuilder& sb, ProfileVersion val); - enum class Stage : SlangStage + enum class Stage : SlangStageIntegral { Unknown = SLANG_STAGE_NONE, #define PROFILE_STAGE(TAG, NAME, VAL) TAG = VAL, 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); diff --git a/source/slang/slang-repro.cpp b/source/slang/slang-repro.cpp index ad1bc25fc..aa4dc92fc 100644 --- a/source/slang/slang-repro.cpp +++ b/source/slang/slang-repro.cpp @@ -373,7 +373,7 @@ static String _scrubName(const String& in) dst->useUnknownImageFormatAsDefault = request->useUnknownImageFormatAsDefault; dst->obfuscateCode = linkage->m_obfuscateCode; - dst->defaultMatrixLayoutMode = linkage->defaultMatrixLayoutMode; + dst->defaultMatrixLayoutMode = SlangMatrixLayoutMode(linkage->defaultMatrixLayoutMode); } // Entry points diff --git a/source/slang/slang-type-system-shared.h b/source/slang/slang-type-system-shared.h index d0972881a..a0b8f45a8 100644 --- a/source/slang/slang-type-system-shared.h +++ b/source/slang/slang-type-system-shared.h @@ -87,14 +87,18 @@ FOREACH_BASE_TYPE(DEFINE_BASE_TYPE) SLANG_FORCE_INLINE bool operator==(const ThisType& rhs) const { return flavor == rhs.flavor; } SLANG_FORCE_INLINE bool operator!=(const ThisType& rhs) const { return !(*this == rhs); } - SlangResourceShape getShape() const { return flavor & 0xFF; } - SlangResourceAccess getAccess() const { return (flavor >> 8) & 0xFF; } + SlangResourceShape getShape() const { return SlangResourceShape(flavor & 0xFF); } + SlangResourceAccess getAccess() const { return SlangResourceAccess((flavor >> 8) & 0xFF); } TextureFlavor() = default; TextureFlavor(uint32_t tag) { flavor = (uint16_t)tag; } static TextureFlavor create(SlangResourceShape shape, SlangResourceAccess access); static TextureFlavor create(SlangResourceShape shape, SlangResourceAccess access, int flags); + + static TextureFlavor create(TextureFlavor::Shape shape, SlangResourceAccess access) { return create(SlangResourceShape(shape), access); } + static TextureFlavor create(TextureFlavor::Shape shape, SlangResourceAccess access, int flags) { return create(SlangResourceShape(shape), access, flags); } + }; enum class SamplerStateFlavor : uint8_t diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 2224c10bf..461d15df5 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -612,7 +612,7 @@ SLANG_NO_THROW SlangResult SLANG_MCALL Session::createCompileRequest(slang::ICom SLANG_NO_THROW SlangProfileID SLANG_MCALL Session::findProfile( char const* name) { - return Slang::Profile::lookUp(name).raw; + return SlangProfileID(Slang::Profile::lookUp(name).raw); } SLANG_NO_THROW SlangCapabilityID SLANG_MCALL Session::findCapability( diff --git a/tools/slang-reflection-test/slang-reflection-test-main.cpp b/tools/slang-reflection-test/slang-reflection-test-main.cpp index 34fef404e..2aabf9ca2 100644 --- a/tools/slang-reflection-test/slang-reflection-test-main.cpp +++ b/tools/slang-reflection-test/slang-reflection-test-main.cpp @@ -318,7 +318,7 @@ static void emitReflectionVarBindingInfoJSON( for(uint32_t cc = 0; cc < categoryCount; ++cc ) { - auto category = var->getCategoryByIndex(cc); + auto category = SlangParameterCategory(var->getCategoryByIndex(cc)); auto index = var->getOffset(category); auto space = var->getBindingSpace(category); auto count = typeLayout->getSize(category); @@ -676,7 +676,7 @@ static void emitReflectionTypeInfoJSON( comma(writer); emitReflectionScalarTypeInfoJSON( writer, - type->getScalarType()); + SlangScalarType(type->getScalarType())); break; case slang::TypeReflection::Kind::Vector: @@ -1364,7 +1364,8 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe SlangCompileRequest* request = spCreateCompileRequest(session); for (int i = 0; i < SLANG_WRITER_CHANNEL_COUNT_OF; ++i) { - spSetWriter(request, SlangWriterChannel(i), stdWriters->getWriter(i)); + const auto channel = SlangWriterChannel(i); + spSetWriter(request, channel, stdWriters->getWriter(channel)); } char const* appName = "slang-reflection-test"; diff --git a/tools/slang-test/slangc-tool.cpp b/tools/slang-test/slangc-tool.cpp index e538cde09..a62ea6975 100644 --- a/tools/slang-test/slangc-tool.cpp +++ b/tools/slang-test/slangc-tool.cpp @@ -38,7 +38,8 @@ SlangResult SlangCTool::innerMain(StdWriters* stdWriters, slang::IGlobalSession* // Do any app specific configuration for (int i = 0; i < SLANG_WRITER_CHANNEL_COUNT_OF; ++i) { - compileRequest->setWriter(SlangWriterChannel(i), stdWriters->getWriter(i)); + const auto channel = SlangWriterChannel(i); + compileRequest->setWriter(channel, stdWriters->getWriter(channel)); } compileRequest->setDiagnosticCallback(&_diagnosticCallback, nullptr); diff --git a/tools/test-server/test-server-main.cpp b/tools/test-server/test-server-main.cpp index b4eead664..77951d3d3 100644 --- a/tools/test-server/test-server-main.cpp +++ b/tools/test-server/test-server-main.cpp @@ -119,7 +119,8 @@ SlangResult innerMain(StdWriters* stdWriters, slang::IGlobalSession* sharedSessi // Do any app specific configuration for (int i = 0; i < SLANG_WRITER_CHANNEL_COUNT_OF; ++i) { - compileRequest->setWriter(SlangWriterChannel(i), stdWriters->getWriter(i)); + const auto channel = SlangWriterChannel(i); + compileRequest->setWriter(channel, stdWriters->getWriter(channel)); } compileRequest->setDiagnosticCallback(&_diagnosticCallback, stdWriters->getWriter(SLANG_WRITER_CHANNEL_STD_ERROR)); |
