Fix usage tracking issue for OpImage.
This commit is contained in:
parent
bbf6b60350
commit
aaf397cd1f
@ -0,0 +1,31 @@
|
|||||||
|
Texture2D<float4> uTexture : register(t0);
|
||||||
|
SamplerState _uTexture_sampler : register(s0);
|
||||||
|
|
||||||
|
static int2 Size;
|
||||||
|
|
||||||
|
struct SPIRV_Cross_Output
|
||||||
|
{
|
||||||
|
int2 Size : SV_Target0;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint2 SPIRV_Cross_textureSize(Texture2D<float4> Tex, uint Level, out uint Param)
|
||||||
|
{
|
||||||
|
uint2 ret;
|
||||||
|
Tex.GetDimensions(Level, ret.x, ret.y, Param);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void frag_main()
|
||||||
|
{
|
||||||
|
uint _19_dummy_parameter;
|
||||||
|
uint _20_dummy_parameter;
|
||||||
|
Size = int2(SPIRV_Cross_textureSize(uTexture, uint(0), _19_dummy_parameter)) + int2(SPIRV_Cross_textureSize(uTexture, uint(1), _20_dummy_parameter));
|
||||||
|
}
|
||||||
|
|
||||||
|
SPIRV_Cross_Output main()
|
||||||
|
{
|
||||||
|
frag_main();
|
||||||
|
SPIRV_Cross_Output stage_output;
|
||||||
|
stage_output.Size = Size;
|
||||||
|
return stage_output;
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
#include <metal_stdlib>
|
||||||
|
#include <simd/simd.h>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
|
||||||
|
struct main0_out
|
||||||
|
{
|
||||||
|
int2 Size [[color(0)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
fragment main0_out main0(texture2d<float> uTexture [[texture(0)]], sampler uTextureSmplr [[sampler(0)]])
|
||||||
|
{
|
||||||
|
main0_out out = {};
|
||||||
|
out.Size = int2(uTexture.get_width(), uTexture.get_height()) + int2(uTexture.get_width(1), uTexture.get_height(1));
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
11
reference/opt/shaders/asm/frag/image-extract-reuse.asm.frag
Normal file
11
reference/opt/shaders/asm/frag/image-extract-reuse.asm.frag
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(binding = 0) uniform sampler2D uTexture;
|
||||||
|
|
||||||
|
layout(location = 0) out ivec2 Size;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Size = textureSize(uTexture, 0) + textureSize(uTexture, 1);
|
||||||
|
}
|
||||||
|
|
31
reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag
Normal file
31
reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
Texture2D<float4> uTexture : register(t0);
|
||||||
|
SamplerState _uTexture_sampler : register(s0);
|
||||||
|
|
||||||
|
static int2 Size;
|
||||||
|
|
||||||
|
struct SPIRV_Cross_Output
|
||||||
|
{
|
||||||
|
int2 Size : SV_Target0;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint2 SPIRV_Cross_textureSize(Texture2D<float4> Tex, uint Level, out uint Param)
|
||||||
|
{
|
||||||
|
uint2 ret;
|
||||||
|
Tex.GetDimensions(Level, ret.x, ret.y, Param);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void frag_main()
|
||||||
|
{
|
||||||
|
uint _19_dummy_parameter;
|
||||||
|
uint _20_dummy_parameter;
|
||||||
|
Size = int2(SPIRV_Cross_textureSize(uTexture, uint(0), _19_dummy_parameter)) + int2(SPIRV_Cross_textureSize(uTexture, uint(1), _20_dummy_parameter));
|
||||||
|
}
|
||||||
|
|
||||||
|
SPIRV_Cross_Output main()
|
||||||
|
{
|
||||||
|
frag_main();
|
||||||
|
SPIRV_Cross_Output stage_output;
|
||||||
|
stage_output.Size = Size;
|
||||||
|
return stage_output;
|
||||||
|
}
|
17
reference/shaders-msl/asm/frag/image-extract-reuse.asm.frag
Normal file
17
reference/shaders-msl/asm/frag/image-extract-reuse.asm.frag
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <metal_stdlib>
|
||||||
|
#include <simd/simd.h>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
|
||||||
|
struct main0_out
|
||||||
|
{
|
||||||
|
int2 Size [[color(0)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
fragment main0_out main0(texture2d<float> uTexture [[texture(0)]], sampler uTextureSmplr [[sampler(0)]])
|
||||||
|
{
|
||||||
|
main0_out out = {};
|
||||||
|
out.Size = int2(uTexture.get_width(), uTexture.get_height()) + int2(uTexture.get_width(1), uTexture.get_height(1));
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
11
reference/shaders/asm/frag/image-extract-reuse.asm.frag
Normal file
11
reference/shaders/asm/frag/image-extract-reuse.asm.frag
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(binding = 0) uniform sampler2D uTexture;
|
||||||
|
|
||||||
|
layout(location = 0) out ivec2 Size;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Size = textureSize(uTexture, 0) + textureSize(uTexture, 1);
|
||||||
|
}
|
||||||
|
|
41
shaders-hlsl/asm/frag/image-extract-reuse.asm.frag
Normal file
41
shaders-hlsl/asm/frag/image-extract-reuse.asm.frag
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
; SPIR-V
|
||||||
|
; Version: 1.0
|
||||||
|
; Generator: Khronos Glslang Reference Front End; 6
|
||||||
|
; Bound: 19
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpCapability ImageQuery
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Fragment %main "main" %Size
|
||||||
|
OpExecutionMode %main OriginUpperLeft
|
||||||
|
OpSource GLSL 450
|
||||||
|
OpName %main "main"
|
||||||
|
OpName %Size "Size"
|
||||||
|
OpName %uTexture "uTexture"
|
||||||
|
OpDecorate %Size Location 0
|
||||||
|
OpDecorate %uTexture DescriptorSet 0
|
||||||
|
OpDecorate %uTexture Binding 0
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v2int = OpTypeVector %int 2
|
||||||
|
%_ptr_Output_v2int = OpTypePointer Output %v2int
|
||||||
|
%Size = OpVariable %_ptr_Output_v2int Output
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%11 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||||
|
%12 = OpTypeSampledImage %11
|
||||||
|
%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12
|
||||||
|
%uTexture = OpVariable %_ptr_UniformConstant_12 UniformConstant
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%int_1 = OpConstant %int 1
|
||||||
|
%main = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%15 = OpLoad %12 %uTexture
|
||||||
|
%17 = OpImage %11 %15
|
||||||
|
%18 = OpImageQuerySizeLod %v2int %17 %int_0
|
||||||
|
%19 = OpImageQuerySizeLod %v2int %17 %int_1
|
||||||
|
%20 = OpIAdd %v2int %18 %19
|
||||||
|
OpStore %Size %20
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
41
shaders-msl/asm/frag/image-extract-reuse.asm.frag
Normal file
41
shaders-msl/asm/frag/image-extract-reuse.asm.frag
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
; SPIR-V
|
||||||
|
; Version: 1.0
|
||||||
|
; Generator: Khronos Glslang Reference Front End; 6
|
||||||
|
; Bound: 19
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpCapability ImageQuery
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Fragment %main "main" %Size
|
||||||
|
OpExecutionMode %main OriginUpperLeft
|
||||||
|
OpSource GLSL 450
|
||||||
|
OpName %main "main"
|
||||||
|
OpName %Size "Size"
|
||||||
|
OpName %uTexture "uTexture"
|
||||||
|
OpDecorate %Size Location 0
|
||||||
|
OpDecorate %uTexture DescriptorSet 0
|
||||||
|
OpDecorate %uTexture Binding 0
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v2int = OpTypeVector %int 2
|
||||||
|
%_ptr_Output_v2int = OpTypePointer Output %v2int
|
||||||
|
%Size = OpVariable %_ptr_Output_v2int Output
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%11 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||||
|
%12 = OpTypeSampledImage %11
|
||||||
|
%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12
|
||||||
|
%uTexture = OpVariable %_ptr_UniformConstant_12 UniformConstant
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%int_1 = OpConstant %int 1
|
||||||
|
%main = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%15 = OpLoad %12 %uTexture
|
||||||
|
%17 = OpImage %11 %15
|
||||||
|
%18 = OpImageQuerySizeLod %v2int %17 %int_0
|
||||||
|
%19 = OpImageQuerySizeLod %v2int %17 %int_1
|
||||||
|
%20 = OpIAdd %v2int %18 %19
|
||||||
|
OpStore %Size %20
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
41
shaders/asm/frag/image-extract-reuse.asm.frag
Normal file
41
shaders/asm/frag/image-extract-reuse.asm.frag
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
; SPIR-V
|
||||||
|
; Version: 1.0
|
||||||
|
; Generator: Khronos Glslang Reference Front End; 6
|
||||||
|
; Bound: 19
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpCapability ImageQuery
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Fragment %main "main" %Size
|
||||||
|
OpExecutionMode %main OriginUpperLeft
|
||||||
|
OpSource GLSL 450
|
||||||
|
OpName %main "main"
|
||||||
|
OpName %Size "Size"
|
||||||
|
OpName %uTexture "uTexture"
|
||||||
|
OpDecorate %Size Location 0
|
||||||
|
OpDecorate %uTexture DescriptorSet 0
|
||||||
|
OpDecorate %uTexture Binding 0
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v2int = OpTypeVector %int 2
|
||||||
|
%_ptr_Output_v2int = OpTypePointer Output %v2int
|
||||||
|
%Size = OpVariable %_ptr_Output_v2int Output
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%11 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||||
|
%12 = OpTypeSampledImage %11
|
||||||
|
%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12
|
||||||
|
%uTexture = OpVariable %_ptr_UniformConstant_12 UniformConstant
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%int_1 = OpConstant %int 1
|
||||||
|
%main = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%15 = OpLoad %12 %uTexture
|
||||||
|
%17 = OpImage %11 %15
|
||||||
|
%18 = OpImageQuerySizeLod %v2int %17 %int_0
|
||||||
|
%19 = OpImageQuerySizeLod %v2int %17 %int_1
|
||||||
|
%20 = OpIAdd %v2int %18 %19
|
||||||
|
OpStore %Size %20
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
@ -7193,7 +7193,9 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
|||||||
{
|
{
|
||||||
uint32_t result_type = ops[0];
|
uint32_t result_type = ops[0];
|
||||||
uint32_t id = ops[1];
|
uint32_t id = ops[1];
|
||||||
auto &e = emit_op(result_type, id, to_expression(ops[2]), true);
|
|
||||||
|
// Suppress usage tracking.
|
||||||
|
auto &e = emit_op(result_type, id, to_expression(ops[2]), true, true);
|
||||||
|
|
||||||
// When using the image, we need to know which variable it is actually loaded from.
|
// When using the image, we need to know which variable it is actually loaded from.
|
||||||
auto *var = maybe_get_backing_variable(ops[2]);
|
auto *var = maybe_get_backing_variable(ops[2]);
|
||||||
|
Loading…
Reference in New Issue
Block a user