mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 12:00:05 +00:00
Fix #2178: Allow specialization constants for texel offsets.
This commit is contained in:
parent
fd593d5f08
commit
4657244018
43
Test/baseResults/spv.specTexture.frag.out
Executable file
43
Test/baseResults/spv.specTexture.frag.out
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
spv.specTexture.frag
|
||||||
|
// Module Version 10000
|
||||||
|
// Generated by (magic number): 80008
|
||||||
|
// Id's are bound by 23
|
||||||
|
|
||||||
|
Capability Shader
|
||||||
|
1: ExtInstImport "GLSL.std.450"
|
||||||
|
MemoryModel Logical GLSL450
|
||||||
|
EntryPoint Fragment 4 "main" 9
|
||||||
|
ExecutionMode 4 OriginLowerLeft
|
||||||
|
Source GLSL 450
|
||||||
|
Name 4 "main"
|
||||||
|
Name 9 "color_out"
|
||||||
|
Name 13 "tex"
|
||||||
|
Name 19 "offs"
|
||||||
|
Decorate 9(color_out) Location 0
|
||||||
|
Decorate 13(tex) DescriptorSet 0
|
||||||
|
Decorate 13(tex) Binding 0
|
||||||
|
Decorate 19(offs) SpecId 1
|
||||||
|
2: TypeVoid
|
||||||
|
3: TypeFunction 2
|
||||||
|
6: TypeFloat 32
|
||||||
|
7: TypeVector 6(float) 4
|
||||||
|
8: TypePointer Output 7(fvec4)
|
||||||
|
9(color_out): 8(ptr) Variable Output
|
||||||
|
10: TypeImage 6(float) 2D sampled format:Unknown
|
||||||
|
11: TypeSampledImage 10
|
||||||
|
12: TypePointer UniformConstant 11
|
||||||
|
13(tex): 12(ptr) Variable UniformConstant
|
||||||
|
15: TypeVector 6(float) 2
|
||||||
|
16: 6(float) Constant 0
|
||||||
|
17: 15(fvec2) ConstantComposite 16 16
|
||||||
|
18: TypeInt 32 1
|
||||||
|
19(offs): 18(int) SpecConstant 0
|
||||||
|
20: TypeVector 18(int) 2
|
||||||
|
21: 20(ivec2) SpecConstantComposite 19(offs) 19(offs)
|
||||||
|
4(main): 2 Function None 3
|
||||||
|
5: Label
|
||||||
|
14: 11 Load 13(tex)
|
||||||
|
22: 7(fvec4) ImageSampleExplicitLod 14 17 Lod ConstOffset 16 21
|
||||||
|
Store 9(color_out) 22
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
10
Test/spv.specTexture.frag
Normal file
10
Test/spv.specTexture.frag
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(constant_id = 1) const int offs = 0;
|
||||||
|
layout(binding = 0) uniform sampler2D tex;
|
||||||
|
layout(location = 0) out vec4 color_out;
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
color_out = textureLodOffset(tex, vec2(0.0, 0.0), 0.0, ivec2(offs, offs));
|
||||||
|
}
|
@ -2013,18 +2013,20 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
|
|||||||
if (arg > 0) {
|
if (arg > 0) {
|
||||||
|
|
||||||
#ifndef GLSLANG_WEB
|
#ifndef GLSLANG_WEB
|
||||||
bool f16ShadowCompare = (*argp)[1]->getAsTyped()->getBasicType() == EbtFloat16 && arg0->getType().getSampler().shadow;
|
bool f16ShadowCompare = (*argp)[1]->getAsTyped()->getBasicType() == EbtFloat16 &&
|
||||||
|
arg0->getType().getSampler().shadow;
|
||||||
if (f16ShadowCompare)
|
if (f16ShadowCompare)
|
||||||
++arg;
|
++arg;
|
||||||
#endif
|
#endif
|
||||||
if (! (*argp)[arg]->getAsConstantUnion())
|
if (! (*argp)[arg]->getAsTyped()->getQualifier().isConstant())
|
||||||
error(loc, "argument must be compile-time constant", "texel offset", "");
|
error(loc, "argument must be compile-time constant", "texel offset", "");
|
||||||
else {
|
else if ((*argp)[arg]->getAsConstantUnion()) {
|
||||||
const TType& type = (*argp)[arg]->getAsTyped()->getType();
|
const TType& type = (*argp)[arg]->getAsTyped()->getType();
|
||||||
for (int c = 0; c < type.getVectorSize(); ++c) {
|
for (int c = 0; c < type.getVectorSize(); ++c) {
|
||||||
int offset = (*argp)[arg]->getAsConstantUnion()->getConstArray()[c].getIConst();
|
int offset = (*argp)[arg]->getAsConstantUnion()->getConstArray()[c].getIConst();
|
||||||
if (offset > resources.maxProgramTexelOffset || offset < resources.minProgramTexelOffset)
|
if (offset > resources.maxProgramTexelOffset || offset < resources.minProgramTexelOffset)
|
||||||
error(loc, "value is out of range:", "texel offset", "[gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]");
|
error(loc, "value is out of range:", "texel offset",
|
||||||
|
"[gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,6 +598,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
"spv.glFragColor.frag",
|
"spv.glFragColor.frag",
|
||||||
"spv.rankShift.comp",
|
"spv.rankShift.comp",
|
||||||
"spv.specConst.vert",
|
"spv.specConst.vert",
|
||||||
|
"spv.specTexture.frag",
|
||||||
"spv.OVR_multiview.vert",
|
"spv.OVR_multiview.vert",
|
||||||
"spv.xfbOffsetOnBlockMembersAssignment.vert",
|
"spv.xfbOffsetOnBlockMembersAssignment.vert",
|
||||||
"spv.xfbOffsetOnStructMembersAssignment.vert",
|
"spv.xfbOffsetOnStructMembersAssignment.vert",
|
||||||
|
Loading…
Reference in New Issue
Block a user