Skip to content

Commit

Permalink
Merge pull request #56 from tfoleyNV/bug-55
Browse files Browse the repository at this point in the history
Bug 55
  • Loading branch information
Tim Foley committed Jul 7, 2017
2 parents af8c0ea + 54519ed commit c47f23c
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 5 deletions.
4 changes: 2 additions & 2 deletions slang.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion source/slang/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
4 changes: 4 additions & 0 deletions source/slang/reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions source/slang/type-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down
13 changes: 13 additions & 0 deletions tests/reflection/gh-55.glsl
Original file line number Diff line number Diff line change
@@ -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()
{}
45 changes: 45 additions & 0 deletions tests/reflection/gh-55.glsl.expected
Original file line number Diff line number Diff line change
@@ -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}
}
]
}
}
}
]
}
}

0 comments on commit c47f23c

Please sign in to comment.