Merge pull request #2302 from KhronosGroup/fix-texture-precision
SPV: RelaxedPrecision: use the result precision for texture sampling.
This commit is contained in:
		
						commit
						8d3f3b7dac
					
				@ -4736,7 +4736,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
 | 
				
			|||||||
        translateArguments(*node->getAsAggregate(), arguments, lvalueCoherentFlags);
 | 
					        translateArguments(*node->getAsAggregate(), arguments, lvalueCoherentFlags);
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        translateArguments(*node->getAsUnaryNode(), arguments);
 | 
					        translateArguments(*node->getAsUnaryNode(), arguments);
 | 
				
			||||||
    spv::Decoration precision = TranslatePrecisionDecoration(node->getOperationPrecision());
 | 
					    spv::Decoration precision = TranslatePrecisionDecoration(node->getType());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    spv::Builder::TextureParameters params = { };
 | 
					    spv::Builder::TextureParameters params = { };
 | 
				
			||||||
    params.sampler = arguments[0];
 | 
					    params.sampler = arguments[0];
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										120
									
								
								Test/baseResults/spv.precisionTexture.frag.out
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										120
									
								
								Test/baseResults/spv.precisionTexture.frag.out
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,120 @@
 | 
				
			|||||||
 | 
					spv.precisionTexture.frag
 | 
				
			||||||
 | 
					// Module Version 10000
 | 
				
			||||||
 | 
					// Generated by (magic number): 8000a
 | 
				
			||||||
 | 
					// Id's are bound by 66
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                              Capability Shader
 | 
				
			||||||
 | 
					               1:             ExtInstImport  "GLSL.std.450"
 | 
				
			||||||
 | 
					                              MemoryModel Logical GLSL450
 | 
				
			||||||
 | 
					                              EntryPoint Fragment 4  "main" 16 57 65
 | 
				
			||||||
 | 
					                              ExecutionMode 4 OriginUpperLeft
 | 
				
			||||||
 | 
					                              Source ESSL 310
 | 
				
			||||||
 | 
					                              Name 4  "main"
 | 
				
			||||||
 | 
					                              Name 9  "v"
 | 
				
			||||||
 | 
					                              Name 13  "texM"
 | 
				
			||||||
 | 
					                              Name 16  "vertex"
 | 
				
			||||||
 | 
					                              Name 21  "texH"
 | 
				
			||||||
 | 
					                              Name 52  "imageM"
 | 
				
			||||||
 | 
					                              Name 57  "coord"
 | 
				
			||||||
 | 
					                              Name 60  "imageH"
 | 
				
			||||||
 | 
					                              Name 65  "fragColor"
 | 
				
			||||||
 | 
					                              Decorate 9(v) RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 13(texM) RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 13(texM) DescriptorSet 0
 | 
				
			||||||
 | 
					                              Decorate 13(texM) Binding 0
 | 
				
			||||||
 | 
					                              Decorate 14 RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 16(vertex) Location 0
 | 
				
			||||||
 | 
					                              Decorate 20 RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 21(texH) DescriptorSet 0
 | 
				
			||||||
 | 
					                              Decorate 21(texH) Binding 1
 | 
				
			||||||
 | 
					                              Decorate 26 RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 34 RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 41 RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 45 RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 52(imageM) RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 52(imageM) DescriptorSet 0
 | 
				
			||||||
 | 
					                              Decorate 52(imageM) Binding 0
 | 
				
			||||||
 | 
					                              Decorate 52(imageM) NonWritable
 | 
				
			||||||
 | 
					                              Decorate 53 RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 57(coord) Flat
 | 
				
			||||||
 | 
					                              Decorate 57(coord) Location 1
 | 
				
			||||||
 | 
					                              Decorate 59 RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 60(imageH) DescriptorSet 0
 | 
				
			||||||
 | 
					                              Decorate 60(imageH) Binding 1
 | 
				
			||||||
 | 
					                              Decorate 60(imageH) NonWritable
 | 
				
			||||||
 | 
					                              Decorate 65(fragColor) RelaxedPrecision
 | 
				
			||||||
 | 
					                              Decorate 65(fragColor) Location 0
 | 
				
			||||||
 | 
					               2:             TypeVoid
 | 
				
			||||||
 | 
					               3:             TypeFunction 2
 | 
				
			||||||
 | 
					               6:             TypeFloat 32
 | 
				
			||||||
 | 
					               7:             TypeVector 6(float) 4
 | 
				
			||||||
 | 
					               8:             TypePointer Function 7(fvec4)
 | 
				
			||||||
 | 
					              10:             TypeImage 6(float) 2D sampled format:Unknown
 | 
				
			||||||
 | 
					              11:             TypeSampledImage 10
 | 
				
			||||||
 | 
					              12:             TypePointer UniformConstant 11
 | 
				
			||||||
 | 
					        13(texM):     12(ptr) Variable UniformConstant
 | 
				
			||||||
 | 
					              15:             TypePointer Input 7(fvec4)
 | 
				
			||||||
 | 
					      16(vertex):     15(ptr) Variable Input
 | 
				
			||||||
 | 
					              17:             TypeVector 6(float) 2
 | 
				
			||||||
 | 
					        21(texH):     12(ptr) Variable UniformConstant
 | 
				
			||||||
 | 
					              29:             TypeInt 32 0
 | 
				
			||||||
 | 
					              30:     29(int) Constant 2
 | 
				
			||||||
 | 
					              31:             TypePointer Input 6(float)
 | 
				
			||||||
 | 
					              42:             TypeVector 6(float) 3
 | 
				
			||||||
 | 
					              50:             TypeImage 6(float) 2D nonsampled format:Rgba32f
 | 
				
			||||||
 | 
					              51:             TypePointer UniformConstant 50
 | 
				
			||||||
 | 
					      52(imageM):     51(ptr) Variable UniformConstant
 | 
				
			||||||
 | 
					              54:             TypeInt 32 1
 | 
				
			||||||
 | 
					              55:             TypeVector 54(int) 2
 | 
				
			||||||
 | 
					              56:             TypePointer Input 55(ivec2)
 | 
				
			||||||
 | 
					       57(coord):     56(ptr) Variable Input
 | 
				
			||||||
 | 
					      60(imageH):     51(ptr) Variable UniformConstant
 | 
				
			||||||
 | 
					              64:             TypePointer Output 7(fvec4)
 | 
				
			||||||
 | 
					   65(fragColor):     64(ptr) Variable Output
 | 
				
			||||||
 | 
					         4(main):           2 Function None 3
 | 
				
			||||||
 | 
					               5:             Label
 | 
				
			||||||
 | 
					            9(v):      8(ptr) Variable Function
 | 
				
			||||||
 | 
					              14:          11 Load 13(texM)
 | 
				
			||||||
 | 
					              18:    7(fvec4) Load 16(vertex)
 | 
				
			||||||
 | 
					              19:   17(fvec2) VectorShuffle 18 18 0 1
 | 
				
			||||||
 | 
					              20:    7(fvec4) ImageSampleImplicitLod 14 19
 | 
				
			||||||
 | 
					                              Store 9(v) 20
 | 
				
			||||||
 | 
					              22:          11 Load 21(texH)
 | 
				
			||||||
 | 
					              23:    7(fvec4) Load 16(vertex)
 | 
				
			||||||
 | 
					              24:   17(fvec2) VectorShuffle 23 23 0 1
 | 
				
			||||||
 | 
					              25:    7(fvec4) ImageSampleImplicitLod 22 24
 | 
				
			||||||
 | 
					                              Store 9(v) 25
 | 
				
			||||||
 | 
					              26:          11 Load 13(texM)
 | 
				
			||||||
 | 
					              27:    7(fvec4) Load 16(vertex)
 | 
				
			||||||
 | 
					              28:   17(fvec2) VectorShuffle 27 27 0 1
 | 
				
			||||||
 | 
					              32:     31(ptr) AccessChain 16(vertex) 30
 | 
				
			||||||
 | 
					              33:    6(float) Load 32
 | 
				
			||||||
 | 
					              34:    7(fvec4) ImageSampleExplicitLod 26 28 Lod 33
 | 
				
			||||||
 | 
					                              Store 9(v) 34
 | 
				
			||||||
 | 
					              35:          11 Load 21(texH)
 | 
				
			||||||
 | 
					              36:    7(fvec4) Load 16(vertex)
 | 
				
			||||||
 | 
					              37:   17(fvec2) VectorShuffle 36 36 0 1
 | 
				
			||||||
 | 
					              38:     31(ptr) AccessChain 16(vertex) 30
 | 
				
			||||||
 | 
					              39:    6(float) Load 38
 | 
				
			||||||
 | 
					              40:    7(fvec4) ImageSampleExplicitLod 35 37 Lod 39
 | 
				
			||||||
 | 
					                              Store 9(v) 40
 | 
				
			||||||
 | 
					              41:          11 Load 13(texM)
 | 
				
			||||||
 | 
					              43:    7(fvec4) Load 16(vertex)
 | 
				
			||||||
 | 
					              44:   42(fvec3) VectorShuffle 43 43 0 1 2
 | 
				
			||||||
 | 
					              45:    7(fvec4) ImageSampleProjImplicitLod 41 44
 | 
				
			||||||
 | 
					                              Store 9(v) 45
 | 
				
			||||||
 | 
					              46:          11 Load 21(texH)
 | 
				
			||||||
 | 
					              47:    7(fvec4) Load 16(vertex)
 | 
				
			||||||
 | 
					              48:   42(fvec3) VectorShuffle 47 47 0 1 2
 | 
				
			||||||
 | 
					              49:    7(fvec4) ImageSampleProjImplicitLod 46 48
 | 
				
			||||||
 | 
					                              Store 9(v) 49
 | 
				
			||||||
 | 
					              53:          50 Load 52(imageM)
 | 
				
			||||||
 | 
					              58:   55(ivec2) Load 57(coord)
 | 
				
			||||||
 | 
					              59:    7(fvec4) ImageRead 53 58
 | 
				
			||||||
 | 
					                              Store 9(v) 59
 | 
				
			||||||
 | 
					              61:          50 Load 60(imageH)
 | 
				
			||||||
 | 
					              62:   55(ivec2) Load 57(coord)
 | 
				
			||||||
 | 
					              63:    7(fvec4) ImageRead 61 62
 | 
				
			||||||
 | 
					                              Store 9(v) 63
 | 
				
			||||||
 | 
					                              Return
 | 
				
			||||||
 | 
					                              FunctionEnd
 | 
				
			||||||
							
								
								
									
										24
									
								
								Test/spv.precisionTexture.frag
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								Test/spv.precisionTexture.frag
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					#version 310 es
 | 
				
			||||||
 | 
					precision mediump float;
 | 
				
			||||||
 | 
					precision mediump int;
 | 
				
			||||||
 | 
					layout(binding = 0) uniform mediump sampler2D texM;
 | 
				
			||||||
 | 
					layout(binding = 1) uniform highp sampler2D texH;
 | 
				
			||||||
 | 
					layout(binding = 0, rgba32f) uniform readonly mediump image2D imageM;
 | 
				
			||||||
 | 
					layout(binding = 1, rgba32f) uniform readonly highp image2D imageH;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					layout(location = 0) in highp vec4 vertex;
 | 
				
			||||||
 | 
					layout(location = 1) flat in highp ivec2 coord;
 | 
				
			||||||
 | 
					layout(location = 0) out vec4 fragColor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void main()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    vec4 v;
 | 
				
			||||||
 | 
					    v = texture(texM, vertex.xy);
 | 
				
			||||||
 | 
					    v = texture(texH, vertex.xy);
 | 
				
			||||||
 | 
					    v = textureLod(texM, vertex.xy, vertex.z);
 | 
				
			||||||
 | 
					    v = textureLod(texH, vertex.xy, vertex.z);
 | 
				
			||||||
 | 
					    v = textureProj(texM, vertex.xyz);
 | 
				
			||||||
 | 
					    v = textureProj(texH, vertex.xyz);
 | 
				
			||||||
 | 
					    v = imageLoad(imageM, coord);
 | 
				
			||||||
 | 
					    v = imageLoad(imageH, coord);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1295,7 +1295,7 @@ TIntermTyped* TParseContext::handleBuiltInFunctionCall(TSourceLoc loc, TIntermNo
 | 
				
			|||||||
    TIntermTyped *result = intermediate.addBuiltInFunctionCall(loc, function.getBuiltInOp(),
 | 
					    TIntermTyped *result = intermediate.addBuiltInFunctionCall(loc, function.getBuiltInOp(),
 | 
				
			||||||
                                                               function.getParamCount() == 1,
 | 
					                                                               function.getParamCount() == 1,
 | 
				
			||||||
                                                               arguments, function.getType());
 | 
					                                                               arguments, function.getType());
 | 
				
			||||||
    if (obeyPrecisionQualifiers())
 | 
					    if (result != nullptr && obeyPrecisionQualifiers())
 | 
				
			||||||
        computeBuiltinPrecisions(*result, function);
 | 
					        computeBuiltinPrecisions(*result, function);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (result == nullptr) {
 | 
					    if (result == nullptr) {
 | 
				
			||||||
 | 
				
			|||||||
@ -377,6 +377,7 @@ INSTANTIATE_TEST_CASE_P(
 | 
				
			|||||||
        "spv.precision.frag",
 | 
					        "spv.precision.frag",
 | 
				
			||||||
        "spv.precisionArgs.frag",
 | 
					        "spv.precisionArgs.frag",
 | 
				
			||||||
        "spv.precisionNonESSamp.frag",
 | 
					        "spv.precisionNonESSamp.frag",
 | 
				
			||||||
 | 
					        "spv.precisionTexture.frag",
 | 
				
			||||||
        "spv.prepost.frag",
 | 
					        "spv.prepost.frag",
 | 
				
			||||||
        "spv.privateVariableTypes.frag",
 | 
					        "spv.privateVariableTypes.frag",
 | 
				
			||||||
        "spv.qualifiers.vert",
 | 
					        "spv.qualifiers.vert",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user