mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-26 11:50:59 +00:00
Add support for GLSL ops with struct/pointer outputs
* This is the functions that return multiple values - Modf/ModfStruct and Frexp/FrexpStruct
This commit is contained in:
@@ -255,6 +255,43 @@ ShaderVariable MatrixInverse(ThreadState &state, uint32_t, const rdcarray<Id> &p
|
||||
return m;
|
||||
}
|
||||
|
||||
ShaderVariable Modf(ThreadState &state, uint32_t, const rdcarray<Id> ¶ms)
|
||||
{
|
||||
CHECK_PARAMS(2);
|
||||
|
||||
ShaderVariable x = state.GetSrc(params[0]);
|
||||
Id iptr = params[1];
|
||||
|
||||
ShaderVariable whole = x;
|
||||
|
||||
for(uint32_t c = 0; c < x.columns; c++)
|
||||
x.value.fv[c] = modff(x.value.fv[c], &whole.value.fv[c]);
|
||||
|
||||
state.WritePointerValue(iptr, whole);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
ShaderVariable ModfStruct(ThreadState &state, uint32_t, const rdcarray<Id> ¶ms)
|
||||
{
|
||||
CHECK_PARAMS(1);
|
||||
|
||||
ShaderVariable x = state.GetSrc(params[0]);
|
||||
|
||||
ShaderVariable ret;
|
||||
ret.rows = 1;
|
||||
ret.columns = 1;
|
||||
ret.isStruct = true;
|
||||
ret.members = {x, x};
|
||||
ret.members[0].name = "_child0";
|
||||
ret.members[1].name = "_child1";
|
||||
|
||||
for(uint32_t c = 0; c < x.columns; c++)
|
||||
ret.members[0].value.fv[c] = modff(x.value.fv[c], &ret.members[1].value.fv[c]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T GLSLMax(T x, T y)
|
||||
{
|
||||
@@ -442,6 +479,43 @@ ShaderVariable SmoothStep(ThreadState &state, uint32_t, const rdcarray<Id> ¶
|
||||
return x;
|
||||
}
|
||||
|
||||
ShaderVariable Frexp(ThreadState &state, uint32_t, const rdcarray<Id> ¶ms)
|
||||
{
|
||||
CHECK_PARAMS(2);
|
||||
|
||||
ShaderVariable x = state.GetSrc(params[0]);
|
||||
Id iptr = params[1];
|
||||
|
||||
ShaderVariable whole = x;
|
||||
|
||||
for(uint32_t c = 0; c < x.columns; c++)
|
||||
x.value.fv[c] = frexpf(x.value.fv[c], &whole.value.iv[c]);
|
||||
|
||||
state.WritePointerValue(iptr, whole);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
ShaderVariable FrexpStruct(ThreadState &state, uint32_t, const rdcarray<Id> ¶ms)
|
||||
{
|
||||
CHECK_PARAMS(1);
|
||||
|
||||
ShaderVariable x = state.GetSrc(params[0]);
|
||||
|
||||
ShaderVariable ret;
|
||||
ret.rows = 1;
|
||||
ret.columns = 1;
|
||||
ret.isStruct = true;
|
||||
ret.members = {x, x};
|
||||
ret.members[0].name = "_child0";
|
||||
ret.members[1].name = "_child1";
|
||||
|
||||
for(uint32_t c = 0; c < x.columns; c++)
|
||||
ret.members[0].value.fv[c] = frexpf(x.value.fv[c], &ret.members[1].value.iv[c]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ShaderVariable Ldexp(ThreadState &state, uint32_t, const rdcarray<Id> ¶ms)
|
||||
{
|
||||
CHECK_PARAMS(2);
|
||||
@@ -617,6 +691,8 @@ void ConfigureGLSLStd450(ExtInstDispatcher &extinst)
|
||||
EXT(Degrees);
|
||||
EXT(Determinant);
|
||||
EXT(MatrixInverse);
|
||||
EXT(Modf);
|
||||
EXT(ModfStruct);
|
||||
EXT(FMin);
|
||||
EXT(UMin);
|
||||
EXT(SMin);
|
||||
@@ -629,6 +705,8 @@ void ConfigureGLSLStd450(ExtInstDispatcher &extinst)
|
||||
EXT(FMix);
|
||||
EXT(Step);
|
||||
EXT(SmoothStep);
|
||||
EXT(Frexp);
|
||||
EXT(FrexpStruct);
|
||||
EXT(Ldexp);
|
||||
EXT(Cross);
|
||||
EXT(FaceForward);
|
||||
|
||||
@@ -1341,6 +1341,25 @@ void main()
|
||||
"%_out_float = OpExtInst %float %glsl450 NClamp %nan %zerof %oneVal",
|
||||
});
|
||||
|
||||
// test ExtInst Modf/ModfStruct and Frexp/FrexpStruct
|
||||
append_tests({
|
||||
"%_x = OpExtInst %float %glsl450 Modf %float_dyn_123_456 %priv_float\n"
|
||||
"%_y = OpLoad %float %priv_float\n"
|
||||
"%_tmp = OpExtInst %f32f32 %glsl450 ModfStruct %float_dyn_789_012\n"
|
||||
"%_z = OpCompositeExtract %float %_tmp 0\n"
|
||||
"%_w = OpCompositeExtract %float %_tmp 1\n"
|
||||
"%_out_float4 = OpCompositeConstruct %float4 %_x %_y %_z %_w\n",
|
||||
|
||||
"%_x = OpExtInst %float %glsl450 Frexp %float_dyn_123_456 %priv_int\n"
|
||||
"%_yi = OpLoad %int %priv_int\n"
|
||||
"%_y = OpConvertSToF %float %_yi\n"
|
||||
"%_tmp = OpExtInst %f32i32 %glsl450 FrexpStruct %float_dyn_789_012\n"
|
||||
"%_z = OpCompositeExtract %float %_tmp 0\n"
|
||||
"%_wi = OpCompositeExtract %int %_tmp 1\n"
|
||||
"%_w = OpConvertSToF %float %_wi\n"
|
||||
"%_out_float4 = OpCompositeConstruct %float4 %_x %_y %_z %_w\n",
|
||||
});
|
||||
|
||||
// test float <-> int conversions
|
||||
append_tests({
|
||||
"%_x = OpConvertUToF %float %uint_dyn_1234\n"
|
||||
@@ -1645,6 +1664,9 @@ void main()
|
||||
%child = OpTypeStruct %float4 %float3 %float
|
||||
%parent = OpTypeStruct %float4 %child %float4x4
|
||||
|
||||
%f32f32 = OpTypeStruct %float %float
|
||||
%f32i32 = OpTypeStruct %float %int
|
||||
|
||||
%ptr_Input_v2f = OpTypePointer Input %v2f
|
||||
%ptr_Input_flatv2f = OpTypePointer Input %flatv2f
|
||||
%ptr_Input_uint = OpTypePointer Input %uint
|
||||
@@ -1653,12 +1675,17 @@ void main()
|
||||
%ptr_Input_float2 = OpTypePointer Input %float2
|
||||
%ptr_Input_float4 = OpTypePointer Input %float4
|
||||
%ptr_Output_float4 = OpTypePointer Output %float4
|
||||
%ptr_Private_int = OpTypePointer Private %int
|
||||
%ptr_Private_float = OpTypePointer Private %float
|
||||
|
||||
%linearData = OpVariable %ptr_Input_v2f Input
|
||||
%flatData = OpVariable %ptr_Input_flatv2f Input
|
||||
%gl_FragCoord = OpVariable %ptr_Input_float4 Input
|
||||
%Color = OpVariable %ptr_Output_float4 Output
|
||||
|
||||
%priv_int = OpVariable %ptr_Private_int Private
|
||||
%priv_float = OpVariable %ptr_Private_float Private
|
||||
|
||||
%flatv2f_test_idx = OpConstant %int 0
|
||||
%flatv2f_intval_idx = OpConstant %int 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user