Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

texelFetch(ld opcodes) assumes swizzles are always in xyzw order #31

Open
albertodemichelis opened this issue Sep 15, 2014 · 0 comments

Comments

@albertodemichelis
Copy link

texelFetch(ld opcodes) is assuming that the "operand 2" swizzle is always in the xyzw order
I'm not sure if this problem only occurs in texelFetch it might occur in othe instructions

here's a shader that reproduces the problem(it fetches a texture with a yzw swizzle)


INPUT

uniform sampler2D ITex0;

struct VS_POSTFX_OUT
{
float4 pos : SV_Position;
float2 uv : TEXCOORD0;
};

// pixel shader

struct PS_POSTFX_OUT
{
float4 color : SV_Target;
};

PS_POSTFX_OUT
PS_POSTFX(VS_POSTFX_OUT input)
{
PS_POSTFX_OUT output = (PS_POSTFX_OUT)0;

int3 screenuv = int3(input.pos.x, input.pos.y, 0);
float4 outputcolor = ITex0.Load(screenuv).xyzw;
output.color = float4(outputcolor.yzw, 1.0f);

return output;

}


ASSEMBLY

//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// ITex0 texture float4 2d 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float xy
// TEXCOORD 0 xy 1 NONE float
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_output o0.xyzw
dcl_temps 1
0: ftoi r0.xy, v0.xyxx
1: mov r0.zw, l(0,0,0,0)
2: ld_indexable(texture2d)(float,float,float,float) r0.xyz, r0.xyzw, t0.yzwx
3: mov o0.xyz, r0.xyzx
4: mov o0.w, l(1.000000)
5: ret
// Approximately 6 instruction slots used


OUTPUT

subroutine void SubroutineType();
struct vec1 {
float x;
};
struct uvec1 {
uint x;
};
struct ivec1 {
int x;
};
layout(std140) uniform;
uniform sampler2D ITex0;
vec4 Input0;
layout(location = 0) out vec4 SV_Target0;

define Output0 SV_Target0

vec4 Temp[1];
ivec4 Temp_int[1];
uvec4 Temp_uint[1];
void main()
{
//--- Start Early Main ---
Input0.xy = gl_FragCoord.xy;
//--- End Early Main ---
//Instruction 6
//FTOI
Temp_int[0].xy = ivec4(Input0.xyxx).xy;
//Instruction 7
//MOV
Temp_int[0].zw = ivec2(0x0, 0x0);
//Instruction 8
//LD
Temp_int[0].xyz = floatBitsToInt(texelFetch(ITex0, Temp_int[0].xy, 0).xyz); //this should be "texelFetch(ITex0, Temp_int[0].xy, 0).xzw"
//Instruction 9
//MOV
Output0.xyz = intBitsToFloat(Temp_int[0].xyz);
//Instruction 10
//MOV
Output0.w = 1.000000;
//Instruction 11
//RET
return;
}

thank you for your time
Alberto

@albertodemichelis albertodemichelis changed the title texelFetch(ld opcodes) assumes swizzles are in the always in xyzw order texelFetch(ld opcodes) assumes swizzles are in always in xyzw order Sep 15, 2014
@albertodemichelis albertodemichelis changed the title texelFetch(ld opcodes) assumes swizzles are in always in xyzw order texelFetch(ld opcodes) assumes swizzles are always in xyzw order Sep 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant