diff --git a/renderdoc/api/replay/shader_types.h b/renderdoc/api/replay/shader_types.h index 5e43f62a2..c277149e0 100644 --- a/renderdoc/api/replay/shader_types.h +++ b/renderdoc/api/replay/shader_types.h @@ -83,6 +83,12 @@ struct ShaderVariable uint32_t x, y, z, w; } u; uint32_t uv[16]; + + struct + { + double x, y, z, w; + } d; + double dv[16]; } value; bool32 isStruct; diff --git a/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp b/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp index 852813d71..d385129d6 100644 --- a/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp +++ b/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp @@ -235,44 +235,15 @@ VarType State::OperationType(const OpcodeType &op) const void DoubleSet(ShaderVariable &var, const double in[2]) { - uint64_t *din = (uint64_t *)in; - uint64_t a = din[0], - b = din[1]; - - // LSB - var.value.u.x = (uint32_t)(a & 0xffffffff); - var.value.u.z = (uint32_t)(b & 0xffffffff); - - a >>= 32; - b >>= 32; - - // MSB - var.value.u.y = (uint32_t)(a & 0xffffffff); - var.value.u.w = (uint32_t)(b & 0xffffffff); - + var.value.d.x = in[0]; + var.value.d.y = in[1]; var.type = eVar_Double; } void DoubleGet(const ShaderVariable &var, double out[2]) { - uint64_t a, b; - - // MSB - a = var.value.u.y; - b = var.value.u.w; - - a <<= 32; - b <<= 32; - - // LSB - a |= var.value.u.x; - b |= var.value.u.z; - - double *da = (double *)&a; - double *db = (double *)&b; - - out[0] = *da; - out[1] = *db; + out[0] = var.value.d.x; + out[1] = var.value.d.y; } ShaderVariable sat(const ShaderVariable &v, const VarType type) diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 423c1c2bc..2ff127ac4 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -1414,19 +1414,31 @@ void GLReplay::FillCBufferValue(WrappedOpenGL &gl, GLuint prog, bool bufferBacke gl.glGetUniformuiv(prog, offs, outVar.value.uv); break; case eVar_Double: - RDCUNIMPLEMENTED("Double uniform variables"); + gl.glGetUniformdv(prog, offs, outVar.value.dv); break; } } if(!rowMajor) { - uint32_t uv[16]; - memcpy(&uv[0], &outVar.value.uv[0], sizeof(uv)); - - for(uint32_t r=0; r < outVar.rows; r++) - for(uint32_t c=0; c < outVar.columns; c++) - outVar.value.uv[r*outVar.columns+c] = uv[c*outVar.rows+r]; + if(outVar.type != eVar_Double) + { + uint32_t uv[16]; + memcpy(&uv[0], &outVar.value.uv[0], sizeof(uv)); + + for(uint32_t r=0; r < outVar.rows; r++) + for(uint32_t c=0; c < outVar.columns; c++) + outVar.value.uv[r*outVar.columns+c] = uv[c*outVar.rows+r]; + } + else + { + double dv[16]; + memcpy(&dv[0], &outVar.value.dv[0], sizeof(dv)); + + for(uint32_t r=0; r < outVar.rows; r++) + for(uint32_t c=0; c < outVar.columns; c++) + outVar.value.dv[r*outVar.columns+c] = dv[c*outVar.rows+r]; + } } } diff --git a/renderdoc/driver/gl/wrappers/gl_uniform_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_uniform_funcs.cpp index 51e272a4f..0e9bbd9d2 100644 --- a/renderdoc/driver/gl/wrappers/gl_uniform_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_uniform_funcs.cpp @@ -176,14 +176,20 @@ bool WrappedOpenGL::Serialise_glProgramUniformMatrix(GLuint program, GLint locat case MAT3x2dv: elemsPerMat = 2*3; break; case MAT2x4fv: + case MAT2x4dv: case MAT4x2fv: + case MAT4x2dv: elemsPerMat = 2*4; break; case MAT3fv: + case MAT3dv: elemsPerMat = 3*3; break; case MAT3x4fv: + case MAT3x4dv: case MAT4x3fv: + case MAT4x3dv: elemsPerMat = 3*4; break; case MAT4fv: + case MAT4dv: elemsPerMat = 4*4; break; default: RDCERR("Unexpected uniform type to Serialise_glProgramUniformMatrix: %d", Type); diff --git a/renderdocui/Code/FormatElement.cs b/renderdocui/Code/FormatElement.cs index 119de780f..f7b8b1a43 100644 --- a/renderdocui/Code/FormatElement.cs +++ b/renderdocui/Code/FormatElement.cs @@ -280,7 +280,7 @@ namespace renderdocui.Code ret.value.fv = new float[16]; ret.value.uv = new uint[16]; ret.value.iv = new int[16]; - ret.value._dv_arr = new double[16]; + ret.value.dv = new double[16]; for (uint row = 0; row < ret.rows; row++) { diff --git a/renderdocui/Interop/CustomMarshaling.cs b/renderdocui/Interop/CustomMarshaling.cs index 117cb87dd..8e203e23f 100644 --- a/renderdocui/Interop/CustomMarshaling.cs +++ b/renderdocui/Interop/CustomMarshaling.cs @@ -55,6 +55,7 @@ namespace renderdoc UInt32, Int32, UInt16, + Double, } // custom attribute that we can apply to structures we want to serialise @@ -502,6 +503,12 @@ namespace renderdoc Marshal.Copy(fieldPtr, val, 0, cma.FixedLength); field.SetValue(ret, val); } + else if (cma.FixedType == CustomFixedType.Double) + { + double[] val = new double[cma.FixedLength]; + Marshal.Copy(fieldPtr, val, 0, cma.FixedLength); + field.SetValue(ret, val); + } else if (cma.FixedType == CustomFixedType.UInt32) { Int32[] val = new Int32[cma.FixedLength]; diff --git a/renderdocui/Interop/Shader.cs b/renderdocui/Interop/Shader.cs index 185e9202f..3fad3fc89 100644 --- a/renderdocui/Interop/Shader.cs +++ b/renderdocui/Interop/Shader.cs @@ -49,33 +49,8 @@ namespace renderdoc [CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 16, FixedType = CustomFixedType.Int32)] public Int32[] iv; - [CustomMarshalAs(CustomUnmanagedType.Skip)] - public double[] _dv_arr; - - public double[] dv - { - get - { - if (_dv_arr == null) - { - UInt64[] ds = { 0, 0 }; - ds[0] = uv[1]; - ds[1] = uv[3]; - - ds[0] <<= 32; - ds[1] <<= 32; - - ds[0] |= uv[0]; - ds[1] |= uv[2]; - - _dv_arr = new double[2]; - _dv_arr[0] = BitConverter.Int64BitsToDouble(unchecked((long)ds[0])); - _dv_arr[1] = BitConverter.Int64BitsToDouble(unchecked((long)ds[1])); - } - - return _dv_arr; - } - } + [CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 16, FixedType = CustomFixedType.Double)] + public double[] dv; }; [CustomMarshalAs(CustomUnmanagedType.Union)] @@ -136,10 +111,12 @@ namespace renderdoc else return String.Format("{0}{1}x{2}", type.Str(), rows, columns); } - public string RowValuesToString(int cols, double x, double y) - { + public string RowValuesToString(int cols, double x, double y, double z, double w) + { if (cols == 1) return Formatter.Format(x); - else return Formatter.Format(x) + ", " + Formatter.Format(y); + else if (cols == 2) return Formatter.Format(x) + ", " + Formatter.Format(y); + else if (cols == 3) return Formatter.Format(x) + ", " + Formatter.Format(y) + ", " + Formatter.Format(z); + else return Formatter.Format(x) + ", " + Formatter.Format(y) + ", " + Formatter.Format(z) + ", " + Formatter.Format(w); } public string RowValuesToString(int cols, float x, float y, float z, float w) @@ -169,7 +146,7 @@ namespace renderdoc public string Row(int row, VarType t) { if(t == VarType.Double) - return RowValuesToString((int)columns, value.dv[row * columns + 0], value.dv[row * columns + 1]); + return RowValuesToString((int)columns, value.dv[row * columns + 0], value.dv[row * columns + 1], value.dv[row * columns + 2], value.dv[row * columns + 3]); else if(t == VarType.Int) return RowValuesToString((int)columns, value.iv[row * columns + 0], value.iv[row * columns + 1], value.iv[row * columns + 2], value.iv[row * columns + 3]); else if(t == VarType.UInt) diff --git a/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs index a9e69d8cb..60a7aee44 100644 --- a/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs +++ b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs @@ -310,7 +310,7 @@ namespace renderdocui.Controls ret[i].value.fv = new float[16]; ret[i].value.uv = new uint[16]; ret[i].value.iv = new int[16]; - ret[i].value._dv_arr = new double[16]; + ret[i].value.dv = new double[16]; } }