diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-11-13 14:17:09 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-13 14:17:09 -0800 |
| commit | c9d94248dc73fe41c344b0a23230e597f7b94a2c (patch) | |
| tree | 07330bef7fc8685f5615212de33250bb32adc918 /slang.h | |
| parent | c9368fe3ec8f8d8bc58947ddb1b5fd2caa4bd70a (diff) | |
Parameter block work (#276)
* Don't auto-enable IR use for compute tests
The `COMPARE_COMPUTE` and `COMPARE_RENDER_COMPUTE` test fixtures were set up to always enable the `-use-ir` flag on Slang, which precludes having any tests that confirm functionality on the old non-IR path (which is still required by our main customer).
This change adds the `-xslang -use-ir` flags explicitly to any compute test cases that left them out, and makes the fixture no longer add it by default.
* Continue building out parameter block support
The initial front-end logic for parameter blocks was already added, but they are still missing a bunch of functionality. This change addresses some of the known issues:
- Bug fix: don't try to emit HLSL `register` bindings for variables that consume whole register spaces/sets
- Overhaul type layout logic so that it can make decisions based on a given code generation target (currently passed in as a `TargetRequest`), which allows us to decide whether or not a parameter block should get its own register set on a per-target basis.
- Always use a register space/set for Vulkan
- Never use a register space/set for HLSL SM 5.0 and lower
- By default, don't use register spaces/sets for HLSL output
- Add a command-line flag and some "target flags" to enable register-space usage for D3D targets
- Hackily add initial support for parameter blocks in the AST-to-AST path
- This just blindly lowers `ParameterBlock<T>` to `T`, which shouldn't quite work
- A more complete overhaul will probably need to wait until the AST-to-AST legalization is changed to use the `LegalType`s from the IR legalization pass.
- Add a compute-based test case to actually run code using parameter blocks
- This file runs test cases both with and without the IR
Diffstat (limited to 'slang.h')
| -rw-r--r-- | slang.h | 28 |
1 files changed, 25 insertions, 3 deletions
@@ -136,6 +136,16 @@ extern "C" }; /*! + @brief Flags to control code generation behavior of a compilation target */ + typedef unsigned int SlangTargetFlags; + enum + { + /* When compiling for a D3D Shader Model 5.1 or higher target, allocate + distinct register spaces for parameter blocks. */ + SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES = 1 << 4, + }; + + /*! @brief Options to control emission of `#line` directives */ typedef unsigned int SlangLineDirectiveMode; @@ -249,10 +259,20 @@ extern "C" /*! @brief Add a code-generation target to be used. */ - SLANG_API void spAddCodeGenTarget( + SLANG_API int spAddCodeGenTarget( SlangCompileRequest* request, SlangCompileTarget target); + SLANG_API void spSetTargetProfile( + SlangCompileRequest* request, + int targetIndex, + SlangProfileID profile); + + SLANG_API void spSetTargetFlags( + SlangCompileRequest* request, + int targetIndex, + SlangTargetFlags flags); + /*! @brief Set the container format to be used for binary output. */ @@ -564,7 +584,9 @@ extern "C" SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT, SLANG_PARAMETER_CATEGORY_SPECIALIZATION_CONSTANT, SLANG_PARAMETER_CATEGORY_PUSH_CONSTANT_BUFFER, - SLANG_PAREMTER_CATEGORY_PARAMETER_BLOCK, + + // HLSL register `space`, Vulkan GLSL `set` + SLANG_PARAMETER_CATEGORY_REGISTER_SPACE, // SLANG_PARAMETER_CATEGORY_COUNT, @@ -825,7 +847,7 @@ namespace slang DescriptorTableSlot = SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT, SpecializationConstant = SLANG_PARAMETER_CATEGORY_SPECIALIZATION_CONSTANT, PushConstantBuffer = SLANG_PARAMETER_CATEGORY_PUSH_CONSTANT_BUFFER, - ParameterBlock = SLANG_PAREMTER_CATEGORY_PARAMETER_BLOCK, + RegisterSpace = SLANG_PARAMETER_CATEGORY_REGISTER_SPACE, }; struct TypeLayoutReflection |
