diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-07-07 08:50:00 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-07 08:50:00 -0700 |
| commit | c47f23c2e61538c55819363f9db47ce946649027 (patch) | |
| tree | 00c8e2aaf83735f86ce6bf71e6781ac579a55f64 | |
| parent | af8c0eae90c76d2c8f745badf6f743cefe15f777 (diff) | |
| parent | 54519ed70fbe154e196d04a8b62f6ea6aeded52a (diff) | |
Merge pull request #56 from tfoleyNV/bug-55
Bug 55
| -rw-r--r-- | slang.h | 4 | ||||
| -rw-r--r-- | source/slang/emit.cpp | 2 | ||||
| -rw-r--r-- | source/slang/reflection.cpp | 4 | ||||
| -rw-r--r-- | source/slang/type-layout.cpp | 5 | ||||
| -rw-r--r-- | tests/reflection/gh-55.glsl | 13 | ||||
| -rw-r--r-- | tests/reflection/gh-55.glsl.expected | 45 |
6 files changed, 68 insertions, 5 deletions
@@ -429,7 +429,7 @@ extern "C" SLANG_PARAMETER_CATEGORY_SAMPLER_STATE, SLANG_PARAMETER_CATEGORY_UNIFORM, SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT, - SLANG_PARAMETER_CATEGORY_SPECIALIZTION_CONSTANT, + SLANG_PARAMETER_CATEGORY_SPECIALIZATION_CONSTANT, SLANG_PARAMETER_CATEGORY_MIXED, }; @@ -660,7 +660,7 @@ namespace slang SamplerState = SLANG_PARAMETER_CATEGORY_SAMPLER_STATE, Uniform = SLANG_PARAMETER_CATEGORY_UNIFORM, DescriptorTableSlot = SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT, - SpecializationConstant = SLANG_PARAMETER_CATEGORY_SPECIALIZTION_CONSTANT, + SpecializationConstant = SLANG_PARAMETER_CATEGORY_SPECIALIZATION_CONSTANT, Mixed = SLANG_PARAMETER_CATEGORY_MIXED, }; diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 79a8277bf..08d2218dc 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -755,7 +755,7 @@ static void emitCallExpr( char d = *cursor++; assert(('0' <= d) && (d <= '9')); - int argIndex = d - '0'; + UInt argIndex = d - '0'; assert((0 <= argIndex) && (argIndex < argCount)); Emit(context, "("); EmitExpr(context, callExpr->Arguments[argIndex]); diff --git a/source/slang/reflection.cpp b/source/slang/reflection.cpp index f71435c6f..b27cc0696 100644 --- a/source/slang/reflection.cpp +++ b/source/slang/reflection.cpp @@ -842,6 +842,10 @@ static void emitReflectionVarBindingInfoJSON( CASE(VERTEX_INPUT, vertexInput); CASE(FRAGMENT_OUTPUT, fragmentOutput); CASE(SAMPLER_STATE, samplerState); + CASE(UNIFORM, uniform); + CASE(DESCRIPTOR_TABLE_SLOT, descriptorTableSlot); + CASE(SPECIALIZATION_CONSTANT, specializationConstant); + CASE(MIXED, mixed); #undef CASE default: diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp index 2fcf64226..fbaec3736 100644 --- a/source/slang/type-layout.cpp +++ b/source/slang/type-layout.cpp @@ -163,10 +163,11 @@ struct Std140LayoutRulesImpl : GLSLConstantBufferLayoutRulesImpl SimpleLayoutInfo GetVectorLayout(SimpleLayoutInfo elementInfo, size_t elementCount) override { assert(elementInfo.kind == LayoutResourceKind::Uniform); + auto size = elementInfo.size * elementCount; SimpleLayoutInfo vectorInfo( LayoutResourceKind::Uniform, - elementInfo.size * elementCount, - RoundUpToPowerOfTwo(elementInfo.size * elementInfo.alignment)); + size, + RoundUpToPowerOfTwo(size)); return vectorInfo; } }; diff --git a/tests/reflection/gh-55.glsl b/tests/reflection/gh-55.glsl new file mode 100644 index 000000000..4ced68c9e --- /dev/null +++ b/tests/reflection/gh-55.glsl @@ -0,0 +1,13 @@ +//TEST(smoke):SIMPLE:-profile ps_4_0 -target reflection-json + +// Confirm fix for GitHub issue #55 + +layout(set = 0, binding = 0) +uniform PerFrameCB +{ + vec2 offset; + vec2 scale; +}; + +void main() +{} diff --git a/tests/reflection/gh-55.glsl.expected b/tests/reflection/gh-55.glsl.expected new file mode 100644 index 000000000..8cdebdcd8 --- /dev/null +++ b/tests/reflection/gh-55.glsl.expected @@ -0,0 +1,45 @@ +result code = 0 +standard error = { +} +standard output = { +{ + "parameters": [ + { + "name": "PerFrameCB", + "binding": {"kind": "descriptorTableSlot", "index": 0}, + "type": { + "kind": "constantBuffer", + "elementType": { + "kind": "struct", + "fields": [ + { + "name": "offset", + "type": { + "kind": "vector", + "elementCount": 2, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 8} + }, + { + "name": "scale", + "type": { + "kind": "vector", + "elementCount": 2, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 8, "size": 8} + } + ] + } + } + } + ] +} +} |
