diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-07-12 11:30:43 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-12 11:30:43 -0700 |
| commit | 6101e483ae8ea9e10db2b5a9423af3cc7fafb710 (patch) | |
| tree | a3d8f4f8873946f58111ae5e7f5034b071c1e824 /source/slang/emit.cpp | |
| parent | 88f451cfafbf3a30033e750873c79f761b2bd1a5 (diff) | |
| parent | 74963469a169b49d61196e3a3b33a903ea8bfede (diff) | |
Merge pull request #79 from tfoleyNV/sample-rate-reflection
Sample rate reflection
Diffstat (limited to 'source/slang/emit.cpp')
| -rw-r--r-- | source/slang/emit.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 0c39a98bd..03cc7d8aa 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -2833,7 +2833,10 @@ struct EmitVisitor // Emit a single `regsiter` semantic, as appropriate for a given resource-type-specific layout info void emitHLSLRegisterSemantic( - VarLayout::ResourceInfo const& info) + VarLayout::ResourceInfo const& info, + + // Keyword to use in the uniform case (`register` for globals, `packoffset` inside a `cbuffer`) + char const* uniformSemanticSpelling = "register") { if( info.kind == LayoutResourceKind::Uniform ) { @@ -2845,7 +2848,9 @@ struct EmitVisitor // units, and then a "component" within that register, based on 4-byte // offsets from there. We cannot support more fine-grained offsets than that. - Emit(": packoffset(c"); + Emit(": "); + Emit(uniformSemanticSpelling); + Emit("(c"); // Size of a logical `c` register in bytes auto registerSize = 16; @@ -2907,7 +2912,8 @@ struct EmitVisitor // Emit all the `register` semantics that are appropriate for a particular variable layout void emitHLSLRegisterSemantics( - RefPtr<VarLayout> layout) + RefPtr<VarLayout> layout, + char const* uniformSemanticSpelling = "register") { if (!layout) return; @@ -2922,7 +2928,7 @@ struct EmitVisitor for( auto rr : layout->resourceInfos ) { - emitHLSLRegisterSemantic(rr); + emitHLSLRegisterSemantic(rr, uniformSemanticSpelling); } } @@ -3026,7 +3032,7 @@ struct EmitVisitor offsetResource.space += cbufferResource->space; } - emitHLSLRegisterSemantic(offsetResource); + emitHLSLRegisterSemantic(offsetResource, "packoffset"); } Emit(";\n"); |
