Commit 7355eebb by John Kessenich

SPV legacy texturing: Smear result of Op*Dref* up to a vector to match

the expectations of old GLSL shadow*() lookups.
parent e770b3e6
......@@ -1214,6 +1214,23 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
}
}
// See if the result type is expecting a smeared result.
// This happens when a legacy shadow*() call is made, which
// gets a vec4 back instead of a float.
Id smearedType = resultType;
if (! isScalarType(resultType)) {
switch (opCode) {
case OpImageSampleDrefImplicitLod:
case OpImageSampleDrefExplicitLod:
case OpImageSampleProjDrefImplicitLod:
case OpImageSampleProjDrefExplicitLod:
resultType = getScalarTypeId(resultType);
break;
default:
break;
}
}
Instruction* textureInst = new Instruction(getUniqueId(), resultType, opCode);
for (int op = 0; op < optArgNum; ++op)
textureInst->addIdOperand(texArgs[op]);
......@@ -1224,7 +1241,14 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
setPrecision(textureInst->getResultId(), precision);
buildPoint->addInstruction(textureInst);
return textureInst->getResultId();
Id resultId = textureInst->getResultId();
// When a smear is needed, do it, as per what was computed
// above when resultType was changed to a scalar type.
if (resultType != smearedType)
resultId = smearScalar(precision, resultId, smearedType);
return resultId;
}
// Comments in header
......
......@@ -5,7 +5,7 @@ Linked vertex stage:
// Module Version 99
// Generated by (magic number): 51a00bb
// Id's are bound by 141
// Id's are bound by 145
Source GLSL 130
Capability Shader
......@@ -24,12 +24,12 @@ Linked vertex stage:
Name 76 "texSampler3D"
Name 92 "texSamplerCube"
Name 102 "shadowSampler1D"
Name 113 "shadowSampler2D"
Name 136 "gl_Position"
Name 140 "gl_VertexID"
Decorate 136(gl_Position) BuiltIn Position
Decorate 140(gl_VertexID) BuiltIn VertexId
Decorate 140(gl_VertexID) NoStaticUse
Name 114 "shadowSampler2D"
Name 140 "gl_Position"
Name 144 "gl_VertexID"
Decorate 140(gl_Position) BuiltIn Position
Decorate 144(gl_VertexID) BuiltIn VertexId
Decorate 144(gl_VertexID) NoStaticUse
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
......@@ -70,15 +70,15 @@ Linked vertex stage:
100: TypeSampledImage 99
101: TypePointer UniformConstant 100
102(shadowSampler1D): 101(ptr) Variable UniformConstant
110: TypeImage 6(float) 2D depth sampled format:Unknown
111: TypeSampledImage 110
112: TypePointer UniformConstant 111
113(shadowSampler2D): 112(ptr) Variable UniformConstant
135: TypePointer Output 18(fvec4)
136(gl_Position): 135(ptr) Variable Output
138: TypeInt 32 1
139: TypePointer Input 138(int)
140(gl_VertexID): 139(ptr) Variable Input
111: TypeImage 6(float) 2D depth sampled format:Unknown
112: TypeSampledImage 111
113: TypePointer UniformConstant 112
114(shadowSampler2D): 113(ptr) Variable UniformConstant
139: TypePointer Output 18(fvec4)
140(gl_Position): 139(ptr) Variable Output
142: TypeInt 32 1
143: TypePointer Input 142(int)
144(gl_VertexID): 143(ptr) Variable Input
4(main): 2 Function None 3
5: Label
8(lod): 7(ptr) Variable Function
......@@ -158,35 +158,39 @@ Linked vertex stage:
104: 12(fvec3) Load 14(coords3D)
105: 6(float) Load 8(lod)
106: 6(float) CompositeExtract 104 2
107: 18(fvec4) ImageSampleDrefExplicitLod 103 104 106 105
108: 18(fvec4) Load 23(color)
109: 18(fvec4) FAdd 108 107
Store 23(color) 109
114: 111 Load 113(shadowSampler2D)
115: 12(fvec3) Load 14(coords3D)
116: 6(float) Load 8(lod)
117: 6(float) CompositeExtract 115 2
118: 18(fvec4) ImageSampleDrefExplicitLod 114 115 117 116
119: 18(fvec4) Load 23(color)
120: 18(fvec4) FAdd 119 118
Store 23(color) 120
121: 100 Load 102(shadowSampler1D)
122: 18(fvec4) Load 20(coords4D)
123: 6(float) Load 8(lod)
124: 6(float) CompositeExtract 122 3
125: 18(fvec4) ImageSampleProjDrefExplicitLod 121 122 124 123
126: 18(fvec4) Load 23(color)
127: 18(fvec4) FAdd 126 125
Store 23(color) 127
128: 111 Load 113(shadowSampler2D)
129: 18(fvec4) Load 20(coords4D)
130: 6(float) Load 8(lod)
131: 6(float) CompositeExtract 129 3
132: 18(fvec4) ImageSampleProjDrefExplicitLod 128 129 131 130
133: 18(fvec4) Load 23(color)
134: 18(fvec4) FAdd 133 132
Store 23(color) 134
107: 6(float) ImageSampleDrefExplicitLod 103 104 106 105
108: 18(fvec4) CompositeConstruct 107 107 107 107
109: 18(fvec4) Load 23(color)
110: 18(fvec4) FAdd 109 108
Store 23(color) 110
115: 112 Load 114(shadowSampler2D)
116: 12(fvec3) Load 14(coords3D)
117: 6(float) Load 8(lod)
118: 6(float) CompositeExtract 116 2
119: 6(float) ImageSampleDrefExplicitLod 115 116 118 117
120: 18(fvec4) CompositeConstruct 119 119 119 119
121: 18(fvec4) Load 23(color)
122: 18(fvec4) FAdd 121 120
Store 23(color) 122
123: 100 Load 102(shadowSampler1D)
124: 18(fvec4) Load 20(coords4D)
125: 6(float) Load 8(lod)
126: 6(float) CompositeExtract 124 3
127: 6(float) ImageSampleProjDrefExplicitLod 123 124 126 125
128: 18(fvec4) CompositeConstruct 127 127 127 127
129: 18(fvec4) Load 23(color)
130: 18(fvec4) FAdd 129 128
Store 23(color) 130
131: 112 Load 114(shadowSampler2D)
132: 18(fvec4) Load 20(coords4D)
133: 6(float) Load 8(lod)
134: 6(float) CompositeExtract 132 3
135: 6(float) ImageSampleProjDrefExplicitLod 131 132 134 133
136: 18(fvec4) CompositeConstruct 135 135 135 135
137: 18(fvec4) Load 23(color)
Store 136(gl_Position) 137
138: 18(fvec4) FAdd 137 136
Store 23(color) 138
141: 18(fvec4) Load 23(color)
Store 140(gl_Position) 141
Return
FunctionEnd
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment