From 7ff7e0a71dd5f1212d5de162c01fbbc0a0e330fb Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 9 Dec 2020 15:17:21 +0000 Subject: [PATCH] Replace fixed C arrays with wrapper class in public interface * These map more naturally to python tuples and are easier to wrap in and out. * We also tidy up the FloatVecVal etc and standardise the members of ShaderValue. --- docs/conf.py | 2 +- docs/python_api/renderdoc/shaders.rst | 12 - qrenderdoc/Code/BufferFormatter.cpp | 46 +- qrenderdoc/Code/Interface/QRDInterface.h | 2 +- .../Code/pyrenderdoc/container_handling.i | 85 ++ qrenderdoc/Code/pyrenderdoc/pyconversion.h | 74 ++ qrenderdoc/Code/pyrenderdoc/pyconversion.i | 51 - qrenderdoc/Code/pyrenderdoc/qrenderdoc.i | 1 + qrenderdoc/Code/pyrenderdoc/renderdoc.i | 38 +- qrenderdoc/Windows/EventBrowser.cpp | 4 +- qrenderdoc/Windows/PixelHistoryView.cpp | 6 +- qrenderdoc/Windows/ShaderViewer.cpp | 56 +- qrenderdoc/Windows/TextureViewer.cpp | 16 +- qrenderdoc/Windows/TimelineBar.cpp | 4 +- renderdoc/api/replay/d3d11_pipestate.h | 33 +- renderdoc/api/replay/d3d12_pipestate.h | 33 +- renderdoc/api/replay/data_types.h | 72 +- renderdoc/api/replay/gl_pipestate.h | 80 +- renderdoc/api/replay/rdcarray.h | 105 +- renderdoc/api/replay/rdcstr.h | 2 +- renderdoc/api/replay/shader_types.h | 188 ++-- renderdoc/api/replay/vk_pipestate.h | 28 +- renderdoc/driver/d3d11/d3d11_context_wrap.cpp | 16 +- renderdoc/driver/d3d11/d3d11_replay.cpp | 7 +- renderdoc/driver/d3d11/d3d11_shaderdebug.cpp | 272 +++--- renderdoc/driver/d3d12/d3d12_replay.cpp | 7 +- renderdoc/driver/d3d12/d3d12_shaderdebug.cpp | 278 +++--- renderdoc/driver/gl/gl_replay.cpp | 17 +- renderdoc/driver/gl/gl_shader_refl.cpp | 3 +- renderdoc/driver/shaders/dxbc/dxbc_debug.cpp | 896 +++++++++--------- .../driver/shaders/dxil/dxil_bytecode.cpp | 16 +- .../driver/shaders/dxil/dxil_disassemble.cpp | 24 +- .../driver/shaders/dxil/dxil_reflect.cpp | 2 +- .../shaders/spirv/spirv_debug_glsl450.cpp | 130 +-- .../shaders/spirv/spirv_debug_setup.cpp | 23 +- .../shaders/spirv/spirv_disassemble.cpp | 36 +- .../driver/shaders/spirv/spirv_processor.cpp | 74 +- .../driver/shaders/spirv/spirv_reflect.cpp | 16 +- .../shaders/spirv/var_dispatch_helpers.h | 35 +- renderdoc/driver/vulkan/vk_common.cpp | 16 +- renderdoc/driver/vulkan/vk_common.h | 2 +- renderdoc/driver/vulkan/vk_pixelhistory.cpp | 4 +- renderdoc/driver/vulkan/vk_replay.cpp | 6 +- renderdoc/driver/vulkan/vk_shaderdebug.cpp | 140 +-- .../driver/vulkan/wrappers/vk_cmd_funcs.cpp | 32 +- .../driver/vulkan/wrappers/vk_queue_funcs.cpp | 16 +- renderdoc/replay/basic_types_tests.cpp | 76 ++ renderdoc/replay/replay_controller.cpp | 4 +- renderdoc/replay/replay_driver.cpp | 10 +- renderdoc/serialise/serialiser.h | 88 ++ util/test/rdtest/shared/Buffer_Truncation.py | 12 +- util/test/rdtest/shared/Draw_Zoo.py | 2 +- util/test/rdtest/testcase.py | 22 +- util/test/tests/D3D11/D3D11_CBuffer_Zoo.py | 4 +- util/test/tests/D3D11/D3D11_PrimitiveID.py | 8 +- .../tests/D3D11/D3D11_Shader_Debug_Zoo.py | 6 +- .../tests/D3D11/D3D11_Shader_Linkage_Zoo.py | 2 +- util/test/tests/D3D12/D3D12_CBuffer_Zoo.py | 4 +- util/test/tests/D3D12/D3D12_PrimitiveID.py | 8 +- .../tests/D3D12/D3D12_Resource_Mapping_Zoo.py | 2 +- .../tests/D3D12/D3D12_Shader_Debug_Zoo.py | 12 +- .../tests/D3D12/D3D12_Shader_Linkage_Zoo.py | 2 +- util/test/tests/Iter_Test.py | 10 +- util/test/tests/Vulkan/VK_Indirect.py | 6 +- util/test/tests/Vulkan/VK_Shader_Debug_Zoo.py | 2 +- util/test/tests/Vulkan/VK_Spec_Constants.py | 6 +- 66 files changed, 1833 insertions(+), 1459 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 77c81a591..cd7119351 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -421,7 +421,7 @@ def build_finished(app, exception): if 'INTERNAL:' not in str(module.__dict__[item].__doc__): items.append('{}.{}'.format(module_name, item)) - items = set(filter(lambda i: re.search('__|SWIG|ResourceId_Null|rdcarray_of|Structured.*List', i) is None, items)) + items = set(filter(lambda i: re.search('__|SWIG|ResourceId_Null|rdcfixedarray_of|rdcarray_of|Structured.*List', i) is None, items)) # Remove any documented/indexed python objects items -= set(app.env.get_domain('py').objects.keys()) diff --git a/docs/python_api/renderdoc/shaders.rst b/docs/python_api/renderdoc/shaders.rst index fda100343..61dd9f6db 100644 --- a/docs/python_api/renderdoc/shaders.rst +++ b/docs/python_api/renderdoc/shaders.rst @@ -129,15 +129,3 @@ Shader Variables .. autoclass:: renderdoc.PointerVal :members: -.. autoclass:: renderdoc.FloatVecVal - :members: - -.. autoclass:: renderdoc.DoubleVecVal - :members: - -.. autoclass:: renderdoc.UIntVecVal - :members: - -.. autoclass:: renderdoc.IntVecVal - :members: - diff --git a/qrenderdoc/Code/BufferFormatter.cpp b/qrenderdoc/Code/BufferFormatter.cpp index 5a5356210..315bd617e 100644 --- a/qrenderdoc/Code/BufferFormatter.cpp +++ b/qrenderdoc/Code/BufferFormatter.cpp @@ -1024,7 +1024,7 @@ static void FillShaderVarData(ShaderVariable &var, const ShaderConstant &elem, c if(objs.isEmpty()) { var.name = "-"; - memset(var.value.dv, 0, sizeof(var.value.dv)); + var.value = ShaderValue(); return; } @@ -1042,21 +1042,21 @@ static void FillShaderVarData(ShaderVariable &var, const ShaderConstant &elem, c src++; if(var.type == VarType::Double) - var.value.dv[dst] = o.toDouble(); + var.value.f64v[dst] = o.toDouble(); if(var.type == VarType::Float || var.type == VarType::Half) - var.value.fv[dst] = o.toFloat(); + var.value.f32v[dst] = o.toFloat(); else if(var.type == VarType::ULong) var.value.u64v[dst] = o.toULongLong(); else if(var.type == VarType::SLong) var.value.s64v[dst] = o.toLongLong(); else if(var.type == VarType::Bool) - var.value.uv[dst] = o.toBool() ? 1 : 0; + var.value.u32v[dst] = o.toBool() ? 1 : 0; else if(var.type == VarType::UInt || var.type == VarType::UShort || var.type == VarType::UByte) - var.value.uv[dst] = o.toUInt(); + var.value.u32v[dst] = o.toUInt(); else if(var.type == VarType::SInt || var.type == VarType::SShort || var.type == VarType::SByte) - var.value.iv[dst] = o.toInt(); + var.value.s32v[dst] = o.toInt(); else - var.value.fv[dst] = o.toFloat(); + var.value.f32v[dst] = o.toFloat(); } } } @@ -1636,9 +1636,9 @@ QString RowString(const ShaderVariable &v, uint32_t row, VarType type) return ToQStr(v.GetPointer()); if(type == VarType::Double) - return RowValuesToString((int)v.columns, v.displayAsHex, v.value.dv[row * v.columns + 0], - v.value.dv[row * v.columns + 1], v.value.dv[row * v.columns + 2], - v.value.dv[row * v.columns + 3]); + return RowValuesToString((int)v.columns, v.displayAsHex, v.value.f64v[row * v.columns + 0], + v.value.f64v[row * v.columns + 1], v.value.f64v[row * v.columns + 2], + v.value.f64v[row * v.columns + 3]); else if(type == VarType::SLong) return RowValuesToString((int)v.columns, v.displayAsHex, v.value.s64v[row * v.columns + 0], v.value.s64v[row * v.columns + 1], v.value.s64v[row * v.columns + 2], @@ -1648,23 +1648,23 @@ QString RowString(const ShaderVariable &v, uint32_t row, VarType type) v.value.u64v[row * v.columns + 1], v.value.u64v[row * v.columns + 2], v.value.u64v[row * v.columns + 3]); else if(type == VarType::SInt || type == VarType::SShort || type == VarType::SByte) - return RowValuesToString((int)v.columns, v.displayAsHex, v.value.iv[row * v.columns + 0], - v.value.iv[row * v.columns + 1], v.value.iv[row * v.columns + 2], - v.value.iv[row * v.columns + 3]); + return RowValuesToString((int)v.columns, v.displayAsHex, v.value.s32v[row * v.columns + 0], + v.value.s32v[row * v.columns + 1], v.value.s32v[row * v.columns + 2], + v.value.s32v[row * v.columns + 3]); else if(type == VarType::UInt || type == VarType::UShort || type == VarType::UByte) - return RowValuesToString((int)v.columns, v.displayAsHex, v.value.uv[row * v.columns + 0], - v.value.uv[row * v.columns + 1], v.value.uv[row * v.columns + 2], - v.value.uv[row * v.columns + 3]); + return RowValuesToString((int)v.columns, v.displayAsHex, v.value.u32v[row * v.columns + 0], + v.value.u32v[row * v.columns + 1], v.value.u32v[row * v.columns + 2], + v.value.u32v[row * v.columns + 3]); else if(type == VarType::Bool) return RowValuesToString((int)v.columns, v.displayAsHex, - v.value.uv[row * v.columns + 0] ? true : false, - v.value.uv[row * v.columns + 1] ? true : false, - v.value.uv[row * v.columns + 2] ? true : false, - v.value.uv[row * v.columns + 3] ? true : false); + v.value.u32v[row * v.columns + 0] ? true : false, + v.value.u32v[row * v.columns + 1] ? true : false, + v.value.u32v[row * v.columns + 2] ? true : false, + v.value.u32v[row * v.columns + 3] ? true : false); else - return RowValuesToString((int)v.columns, v.displayAsHex, v.value.fv[row * v.columns + 0], - v.value.fv[row * v.columns + 1], v.value.fv[row * v.columns + 2], - v.value.fv[row * v.columns + 3]); + return RowValuesToString((int)v.columns, v.displayAsHex, v.value.f32v[row * v.columns + 0], + v.value.f32v[row * v.columns + 1], v.value.f32v[row * v.columns + 2], + v.value.f32v[row * v.columns + 3]); } QString VarString(const ShaderVariable &v) diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index 044a57917..3e7d6d1d6 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -1365,7 +1365,7 @@ struct EventBookmark DOCUMENT(""); EventBookmark() = default; EventBookmark(uint32_t e) : eventId(e) {} - bool operator==(const EventBookmark &o) { return eventId == o.eventId; } + bool operator==(const EventBookmark &o) const { return eventId == o.eventId; } bool operator!=(const EventBookmark &o) const { return eventId != o.eventId; } bool operator<(const EventBookmark &o) const { return eventId < o.eventId; } }; diff --git a/qrenderdoc/Code/pyrenderdoc/container_handling.i b/qrenderdoc/Code/pyrenderdoc/container_handling.i index 63cb79afb..890e134b8 100644 --- a/qrenderdoc/Code/pyrenderdoc/container_handling.i +++ b/qrenderdoc/Code/pyrenderdoc/container_handling.i @@ -406,3 +406,88 @@ void ARRAY_INSTANTIATION_CHECK_NAME(arrayType)(arrayType *) %} %enddef + +///////////////////////////////////////////////////////////////////////// +// Similar to above for handling templated container, but for fixed array +// it's simpler because we map it to a tuple. Since tuples are immutable +// we only need conversion in and out + +%define TEMPLATE_FIXEDARRAY_DECLARE(typeName) + +%typemap(in) const typeName & { + static_assert(false, "Error! Should not use this typemap"); +} + +%typemap(in) typeName { + static_assert(false, "Error! Should not use this typemap"); +} + +%typemap(in) typeName * (unsigned char tempmem[16*8]) { + using array_type = std::remove_pointer::type; + + { + tempalloc($1, tempmem); + + int failIdx = 0; + int res = TypeConversion::ConvertFromPy($input, indirect($1), &failIdx); + + if(!SWIG_IsOK(res)) + { + if(res == SWIG_TypeError) + { + SWIG_exception_fail(SWIG_ArgError(res), "in method '$symname' argument $argnum of type '$1_basetype'"); + } + else + { + snprintf(convert_error, sizeof(convert_error)-1, "in method '$symname' argument $argnum of type '$1_basetype', decoding element %d", failIdx); + SWIG_exception_fail(SWIG_ArgError(res), convert_error); + } + } + } +} + +%typemap(out) typeName { + $result = ConvertToPy(indirect($1)); +} + +%typemap(out) typeName * { + $result = ConvertToPy(indirect($1)); +} + +// add a check to make sure that we explicitly instantiate all uses of this template (as a reference +// type, not as a purely in parameter to a function - those are converted by value to C++ to allow +// passing pure lists that aren't C++ side at all). +%header %{ +template +void ARRAY_INSTANTIATION_CHECK_NAME(typeName)(typeName *); +%} + +// override these typemaps to instantiate a checking template. +%typemap(check) typeName * { ARRAY_INSTANTIATION_CHECK_NAME(typeName)($1); } +%typemap(check) typeName & { ARRAY_INSTANTIATION_CHECK_NAME(typeName)($1); } +%typemap(check) typeName { ARRAY_INSTANTIATION_CHECK_NAME(typeName)($1); } +%typemap(ret) typeName * { ARRAY_INSTANTIATION_CHECK_NAME(typeName)($1); } +%typemap(ret) typeName & { ARRAY_INSTANTIATION_CHECK_NAME(typeName)($1); } +%typemap(ret) typeName { ARRAY_INSTANTIATION_CHECK_NAME(typeName)(&$1); } + +%enddef + +%define TEMPLATE_FIXEDARRAY_INSTANTIATE(arrayType, innerType, size) + +// instantiate template +%rename(arrayType##_of_##size##_##innerType) arrayType; +%template(arrayType##_of_##size##_##innerType) arrayType; + +%header %{ + +template<> +void ARRAY_INSTANTIATION_CHECK_NAME(arrayType)(arrayType *) +{ +} + +%} + +%enddef + + + diff --git a/qrenderdoc/Code/pyrenderdoc/pyconversion.h b/qrenderdoc/Code/pyrenderdoc/pyconversion.h index 8d447c1ed..86da52269 100644 --- a/qrenderdoc/Code/pyrenderdoc/pyconversion.h +++ b/qrenderdoc/Code/pyrenderdoc/pyconversion.h @@ -602,6 +602,80 @@ struct TypeConversion, false> static PyObject *ConvertToPy(const rdcarray &in) { return ConvertToPy(in, NULL); } }; +template +struct TypeConversion, false> +{ + static swig_type_info *GetTypeInfo() + { + static swig_type_info *cached_type_info = NULL; + static rdcstr typeName = "rdcfixedarray < " + TypeName() + "," + ToStr((uint32_t)N) + " > *"; + + if(cached_type_info) + return cached_type_info; + + cached_type_info = SWIG_TypeQuery(typeName.c_str()); + + return cached_type_info; + } + + // we add some extra parameters so the typemaps for array can use these to get + // nicer failure error messages out with the index that failed + static int ConvertFromPy(PyObject *in, rdcfixedarray &out, int *failIdx) + { + if(!PySequence_Check(in)) + return SWIG_TypeError; + + Py_ssize_t size = PySequence_Size(in); + + if(size != N) + return SWIG_TypeError; + + for(size_t i = 0; i < N; i++) + { + int ret = TypeConversion::ConvertFromPy(PySequence_GetItem(in, i), out[i]); + + if(!SWIG_IsOK(ret)) + { + if(failIdx) + *failIdx = (int)i; + return ret; + } + } + + return SWIG_OK; + } + + static int ConvertFromPy(PyObject *in, rdcfixedarray &out) + { + return ConvertFromPy(in, out, NULL); + } + + static PyObject *ConvertToPy(const rdcfixedarray &in, int *failIdx) + { + PyObject *ret = PyTuple_New(N); + if(!ret) + return NULL; + + for(size_t i = 0; i < N; i++) + { + PyObject *obj = TypeConversion::ConvertToPy(in[i]); + if(!obj) + { + if(failIdx) + *failIdx = 0; + Py_XDECREF(ret); + return NULL; + } + + PyTuple_SetItem(ret, i, obj); + } + + return ret; + } + + static PyObject *ConvertToPy(const rdcfixedarray &in) { return ConvertToPy(in, NULL); } +}; + // specialisation for string template <> struct TypeConversion diff --git a/qrenderdoc/Code/pyrenderdoc/pyconversion.i b/qrenderdoc/Code/pyrenderdoc/pyconversion.i index f67c0f6c7..130e92f64 100644 --- a/qrenderdoc/Code/pyrenderdoc/pyconversion.i +++ b/qrenderdoc/Code/pyrenderdoc/pyconversion.i @@ -2,57 +2,6 @@ %define STRINGIZE(val) #val %enddef -/////////////////////////////////////////////////////////////////////////////////////////////// -// typemaps for more sensible fixed-array handling, based on typemaps from SWIG documentation - -%define FIXED_ARRAY_TYPEMAPS(BaseType) - -%typemap(out) BaseType [ANY] { - $result = PyList_New($1_dim0); - for(int i = 0; i < $1_dim0; i++) - { - PyObject *o = TypeConversion::ConvertToPy( $1[i]); - if(!o) - { - snprintf(convert_error, sizeof(convert_error)-1, "in method '$symname' returning type '$1_basetype', encoding element %d", i); - SWIG_exception_fail(SWIG_ValueError, convert_error); - } - PyList_SetItem($result,i,o); - } -} - -%typemap(arginit) BaseType [ANY] { - $1 = NULL; -} - -%typemap(in) BaseType [ANY] { - if(!PySequence_Check($input)) - { - SWIG_exception_fail(SWIG_TypeError, "in method '$symname' argument $argnum of type '$1_basetype'. Expected sequence"); - } - if(PySequence_Length($input) != $1_dim0) { - SWIG_exception_fail(SWIG_ValueError, "in method '$symname' argument $argnum of type '$1_basetype'. Expected $1_dim0 elements"); - } - $1 = new BaseType[$1_dim0]; - for(int i = 0; i < $1_dim0; i++) { - PyObject *o = PySequence_GetItem($input,i); - - int res = TypeConversion::ConvertFromPy(o, $1[i]); - - if(!SWIG_IsOK(res)) - { - snprintf(convert_error, sizeof(convert_error)-1, "in method '$symname' argument $argnum of type '$1_basetype', decoding element %d", i); - SWIG_exception_fail(SWIG_ArgError(res), convert_error); - } - } -} - -%typemap(freearg) BaseType [ANY] { - delete[] $1; -} - -%enddef - /////////////////////////////////////////////////////////////////////////////////////////////// // simple typemaps for an object that's converted directly by-value. This is perfect for python // immutable objects like strings or datetimes diff --git a/qrenderdoc/Code/pyrenderdoc/qrenderdoc.i b/qrenderdoc/Code/pyrenderdoc/qrenderdoc.i index 596db63c0..862c5257a 100644 --- a/qrenderdoc/Code/pyrenderdoc/qrenderdoc.i +++ b/qrenderdoc/Code/pyrenderdoc/qrenderdoc.i @@ -31,6 +31,7 @@ %import "renderdoc.i" TEMPLATE_ARRAY_DECLARE(rdcarray); +TEMPLATE_FIXEDARRAY_DECLARE(rdcfixedarray); // pass QWidget objects to PySide %{ diff --git a/qrenderdoc/Code/pyrenderdoc/renderdoc.i b/qrenderdoc/Code/pyrenderdoc/renderdoc.i index 3375a1633..1f568d2a8 100644 --- a/qrenderdoc/Code/pyrenderdoc/renderdoc.i +++ b/qrenderdoc/Code/pyrenderdoc/renderdoc.i @@ -87,6 +87,8 @@ %ignore rdcdatetime; %ignore rdcstr; %ignore rdcinflexiblestr; +%ignore rdcfixedarray; +%ignore rdcfixedarray::operator[]; %ignore rdcliteral; %ignore rdcpair; %ignore bytebuf; @@ -198,19 +200,6 @@ SIMPLE_TYPEMAPS(rdcinflexiblestr) SIMPLE_TYPEMAPS(rdcdatetime) SIMPLE_TYPEMAPS(bytebuf) -FIXED_ARRAY_TYPEMAPS(ResourceId) -FIXED_ARRAY_TYPEMAPS(double) -FIXED_ARRAY_TYPEMAPS(float) -FIXED_ARRAY_TYPEMAPS(bool) -FIXED_ARRAY_TYPEMAPS(uint64_t) -FIXED_ARRAY_TYPEMAPS(int64_t) -FIXED_ARRAY_TYPEMAPS(uint32_t) -FIXED_ARRAY_TYPEMAPS(int32_t) -FIXED_ARRAY_TYPEMAPS(uint16_t) -FIXED_ARRAY_TYPEMAPS(int16_t) -FIXED_ARRAY_TYPEMAPS(uint8_t) -FIXED_ARRAY_TYPEMAPS(int8_t) - REFCOUNTED_TYPE(SDChunk); REFCOUNTED_TYPE(SDObject); @@ -229,6 +218,7 @@ NON_TEMPLATE_ARRAY_INSTANTIATE(StructuredBufferList) // these types are to be treated like python lists/arrays, and will be instantiated after declaration // below TEMPLATE_ARRAY_DECLARE(rdcarray); +TEMPLATE_FIXEDARRAY_DECLARE(rdcfixedarray); /////////////////////////////////////////////////////////////////////////////////////////// // Actually include header files here. Note that swig is configured not to recurse, so we @@ -319,6 +309,28 @@ EXTEND_ARRAY_CLASS_METHODS(StructuredChunkList) EXTEND_ARRAY_CLASS_METHODS(StructuredObjectList) EXTEND_ARRAY_CLASS_METHODS(StructuredBufferList) +// If you get an error with add_your_use_of_rdcfixedarray_to_swig_interface missing, add your type here +// or in qrenderdoc.i, depending on which one is appropriate +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, float, 2) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, float, 4) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint32_t, 3) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint32_t, 4) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint64_t, 4) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, int32_t, 4) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, ResourceId, 4) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, ResourceId, 8) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, bool, 8) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, float, 16) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, int32_t, 16) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint32_t, 16) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, double, 16) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint64_t, 16) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, int64_t, 16) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint16_t, 16) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, int16_t, 16) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint8_t, 16) +TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, int8_t, 16) + // list of array types. These are the concrete types used in rdcarray that will be bound // If you get an error with add_your_use_of_rdcarray_to_swig_interface missing, add your type here // or in qrenderdoc.i, depending on which one is appropriate diff --git a/qrenderdoc/Windows/EventBrowser.cpp b/qrenderdoc/Windows/EventBrowser.cpp index 76afa48b3..298b48c59 100644 --- a/qrenderdoc/Windows/EventBrowser.cpp +++ b/qrenderdoc/Windows/EventBrowser.cpp @@ -388,10 +388,10 @@ QPair EventBrowser::AddDrawcalls(RDTreeWidgetItem *parent, if(m_Ctx.Config().EventBrowser_ApplyColors) { // if alpha isn't 0, assume the colour is valid - if((d.flags & (DrawFlags::PushMarker | DrawFlags::SetMarker)) && d.markerColor[3] > 0.0f) + if((d.flags & (DrawFlags::PushMarker | DrawFlags::SetMarker)) && d.markerColor.w > 0.0f) { QColor col = QColor::fromRgb( - qRgb(d.markerColor[0] * 255.0f, d.markerColor[1] * 255.0f, d.markerColor[2] * 255.0f)); + qRgb(d.markerColor.x * 255.0f, d.markerColor.y * 255.0f, d.markerColor.z * 255.0f)); child->setTreeColor(col, 3.0f); diff --git a/qrenderdoc/Windows/PixelHistoryView.cpp b/qrenderdoc/Windows/PixelHistoryView.cpp index 3aa910e37..f4cf6c7d2 100644 --- a/qrenderdoc/Windows/PixelHistoryView.cpp +++ b/qrenderdoc/Windows/PixelHistoryView.cpp @@ -232,8 +232,7 @@ public: .arg(mods.front().eventId) .arg(drawcall->name); - if(memcmp(mods[0].preMod.col.uintValue, mods[0].postMod.col.uintValue, - sizeof(uint32_t) * 4) == 0) + if(mods[0].preMod.col.uintValue == mods[0].postMod.col.uintValue) { ret += tr("\nNo change in tex value"); uavnowrite = true; @@ -356,8 +355,7 @@ public: passed |= m.Passed(); if(mods[0].directShaderWrite && - memcmp(mods[0].preMod.col.uintValue, mods[0].postMod.col.uintValue, - sizeof(uint32_t) * 4) == 0) + mods[0].preMod.col.uintValue == mods[0].postMod.col.uintValue) return QBrush(QColor::fromRgb(235, 235, 235)); return passed ? QBrush(QColor::fromRgb(235, 255, 235)) diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index b8f693638..293a74063 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -2433,7 +2433,7 @@ bool ShaderViewer::getVar(RDTreeWidgetItem *item, ShaderVariable *var, QString * if(mapping.type == VarType::Double || mapping.type == VarType::ULong) ret.value.u64v[i] = reg->value.u64v[r.component]; else - ret.value.uv[i] = reg->value.uv[r.component]; + ret.value.u32v[i] = reg->value.u32v[r.component]; } else { @@ -3314,27 +3314,27 @@ void ShaderViewer::updateWatchVariables() if(regcast == QLatin1Char('i')) { - val += Formatter::Format(var.value.iv[elindex]); + val += Formatter::Format(var.value.s32v[elindex]); } else if(regcast == QLatin1Char('f')) { - val += Formatter::Format(var.value.fv[elindex]); + val += Formatter::Format(var.value.f32v[elindex]); } else if(regcast == QLatin1Char('u')) { - val += Formatter::Format(var.value.uv[elindex]); + val += Formatter::Format(var.value.u32v[elindex]); } else if(regcast == QLatin1Char('x')) { - val += Formatter::Format(var.value.uv[elindex], true); + val += Formatter::Format(var.value.u32v[elindex], true); } else if(regcast == QLatin1Char('b')) { - val += QFormatStr("%1").arg(var.value.uv[elindex], 32, 2, QLatin1Char('0')); + val += QFormatStr("%1").arg(var.value.u32v[elindex], 32, 2, QLatin1Char('0')); } else if(regcast == QLatin1Char('d')) { - val += Formatter::Format(var.value.dv[elindex]); + val += Formatter::Format(var.value.f64v[elindex]); } if(s < swizzle.count() - 1) @@ -3632,15 +3632,15 @@ RDTreeWidgetItem *ShaderViewer::makeSourceVariableNode(const SourceVariableMappi } if(l.type == VarType::UInt) - value += Formatter::Format(reg->value.uv[r.component]); + value += Formatter::Format(reg->value.u32v[r.component]); else if(l.type == VarType::SInt) - value += Formatter::Format(reg->value.iv[r.component]); + value += Formatter::Format(reg->value.s32v[r.component]); else if(l.type == VarType::Bool) - value += Formatter::Format(reg->value.uv[r.component] ? true : false); + value += Formatter::Format(reg->value.u32v[r.component] ? true : false); else if(l.type == VarType::Float) - value += Formatter::Format(reg->value.fv[r.component]); + value += Formatter::Format(reg->value.f32v[r.component]); else if(l.type == VarType::Double) - value += Formatter::Format(reg->value.dv[r.component]); + value += Formatter::Format(reg->value.f64v[r.component]); } else { @@ -4608,25 +4608,25 @@ void ShaderViewer::updateVariableTooltip() "--------------------------------------------------------\n"); text += QFormatStr("float | %1 %2 %3 %4\n") - .arg(Formatter::Format(var.value.fv[0]), 11) - .arg(Formatter::Format(var.value.fv[1]), 11) - .arg(Formatter::Format(var.value.fv[2]), 11) - .arg(Formatter::Format(var.value.fv[3]), 11); + .arg(Formatter::Format(var.value.f32v[0]), 11) + .arg(Formatter::Format(var.value.f32v[1]), 11) + .arg(Formatter::Format(var.value.f32v[2]), 11) + .arg(Formatter::Format(var.value.f32v[3]), 11); text += QFormatStr("uint | %1 %2 %3 %4\n") - .arg(var.value.uv[0], 11, 10, QLatin1Char(' ')) - .arg(var.value.uv[1], 11, 10, QLatin1Char(' ')) - .arg(var.value.uv[2], 11, 10, QLatin1Char(' ')) - .arg(var.value.uv[3], 11, 10, QLatin1Char(' ')); + .arg(var.value.u32v[0], 11, 10, QLatin1Char(' ')) + .arg(var.value.u32v[1], 11, 10, QLatin1Char(' ')) + .arg(var.value.u32v[2], 11, 10, QLatin1Char(' ')) + .arg(var.value.u32v[3], 11, 10, QLatin1Char(' ')); text += QFormatStr("int | %1 %2 %3 %4\n") - .arg(var.value.iv[0], 11, 10, QLatin1Char(' ')) - .arg(var.value.iv[1], 11, 10, QLatin1Char(' ')) - .arg(var.value.iv[2], 11, 10, QLatin1Char(' ')) - .arg(var.value.iv[3], 11, 10, QLatin1Char(' ')); + .arg(var.value.s32v[0], 11, 10, QLatin1Char(' ')) + .arg(var.value.s32v[1], 11, 10, QLatin1Char(' ')) + .arg(var.value.s32v[2], 11, 10, QLatin1Char(' ')) + .arg(var.value.s32v[3], 11, 10, QLatin1Char(' ')); text += QFormatStr("hex | %1 %2 %3 %4") - .arg(Formatter::HexFormat(var.value.uv[0], 4)) - .arg(Formatter::HexFormat(var.value.uv[1], 4)) - .arg(Formatter::HexFormat(var.value.uv[2], 4)) - .arg(Formatter::HexFormat(var.value.uv[3], 4)); + .arg(Formatter::HexFormat(var.value.u32v[0], 4)) + .arg(Formatter::HexFormat(var.value.u32v[1], 4)) + .arg(Formatter::HexFormat(var.value.u32v[2], 4)) + .arg(Formatter::HexFormat(var.value.u32v[3], 4)); text += lit(""); QToolTip::showText(m_TooltipPos, text); diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 76b72a84d..2cb7344e5 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -1668,8 +1668,8 @@ void TextureViewer::UI_UpdateChannels() m_TexDisplay.hdrMultiplier = -1.0f; if(m_TexDisplay.customShaderId != ResourceId()) { - memset(m_CurPixelValue.floatValue, 0, sizeof(float) * 4); - memset(m_CurRealValue.floatValue, 0, sizeof(float) * 4); + m_CurPixelValue.floatValue = {0.0f, 0.0f, 0.0f, 0.0f}; + m_CurRealValue.floatValue = {0.0f, 0.0f, 0.0f, 0.0f}; UI_UpdateStatusText(); } m_TexDisplay.customShaderId = ResourceId(); @@ -1707,8 +1707,8 @@ void TextureViewer::UI_UpdateChannels() m_TexDisplay.hdrMultiplier = -1.0f; if(m_TexDisplay.customShaderId != ResourceId()) { - memset(m_CurPixelValue.floatValue, 0, sizeof(float) * 4); - memset(m_CurRealValue.floatValue, 0, sizeof(float) * 4); + m_CurPixelValue.floatValue = {0.0f, 0.0f, 0.0f, 0.0f}; + m_CurRealValue.floatValue = {0.0f, 0.0f, 0.0f, 0.0f}; UI_UpdateStatusText(); } m_TexDisplay.customShaderId = ResourceId(); @@ -1748,8 +1748,8 @@ void TextureViewer::UI_UpdateChannels() m_TexDisplay.hdrMultiplier = mul; if(m_TexDisplay.customShaderId != ResourceId()) { - memset(m_CurPixelValue.floatValue, 0, sizeof(float) * 4); - memset(m_CurRealValue.floatValue, 0, sizeof(float) * 4); + m_CurPixelValue.floatValue = {0.0f, 0.0f, 0.0f, 0.0f}; + m_CurRealValue.floatValue = {0.0f, 0.0f, 0.0f, 0.0f}; UI_UpdateStatusText(); } m_TexDisplay.customShaderId = ResourceId(); @@ -1787,8 +1787,8 @@ void TextureViewer::UI_UpdateChannels() { if(m_TexDisplay.customShaderId == ResourceId()) { - memset(m_CurPixelValue.floatValue, 0, sizeof(float) * 4); - memset(m_CurRealValue.floatValue, 0, sizeof(float) * 4); + m_CurPixelValue.floatValue = {0.0f, 0.0f, 0.0f, 0.0f}; + m_CurRealValue.floatValue = {0.0f, 0.0f, 0.0f, 0.0f}; UI_UpdateStatusText(); } m_TexDisplay.customShaderId = m_CustomShaders[shaderName]; diff --git a/qrenderdoc/Windows/TimelineBar.cpp b/qrenderdoc/Windows/TimelineBar.cpp index 6148b39ef..809718899 100644 --- a/qrenderdoc/Windows/TimelineBar.cpp +++ b/qrenderdoc/Windows/TimelineBar.cpp @@ -1028,10 +1028,10 @@ uint32_t TimelineBar::processDraws(QVector &markers, QVector & maxEID = qMax(maxEID, m.eidEnd); - if(d.markerColor[3] > 0.0f) + if(d.markerColor.w > 0.0f) { m.color = QColor::fromRgb( - qRgb(d.markerColor[0] * 255.0f, d.markerColor[1] * 255.0f, d.markerColor[2] * 255.0f)); + qRgb(d.markerColor.x * 255.0f, d.markerColor.y * 255.0f, d.markerColor.z * 255.0f)); } else { diff --git a/renderdoc/api/replay/d3d11_pipestate.h b/renderdoc/api/replay/d3d11_pipestate.h index d8abb7879..3325e8aa5 100644 --- a/renderdoc/api/replay/d3d11_pipestate.h +++ b/renderdoc/api/replay/d3d11_pipestate.h @@ -300,11 +300,10 @@ struct Sampler bool operator==(const Sampler &o) const { return resourceId == o.resourceId && addressU == o.addressU && addressV == o.addressV && - addressW == o.addressW && borderColor[0] == o.borderColor[0] && - borderColor[1] == o.borderColor[1] && borderColor[2] == o.borderColor[2] && - borderColor[3] == o.borderColor[3] && compareFunction == o.compareFunction && - filter == o.filter && maxAnisotropy == o.maxAnisotropy && maxLOD == o.maxLOD && - minLOD == o.minLOD && mipLODBias == o.mipLODBias; + addressW == o.addressW && borderColor == o.borderColor && + compareFunction == o.compareFunction && filter == o.filter && + maxAnisotropy == o.maxAnisotropy && maxLOD == o.maxLOD && minLOD == o.minLOD && + mipLODBias == o.mipLODBias; } bool operator<(const Sampler &o) const { @@ -316,14 +315,8 @@ struct Sampler return addressV < o.addressV; if(!(addressW == o.addressW)) return addressW < o.addressW; - if(!(borderColor[0] == o.borderColor[0])) - return borderColor[0] < o.borderColor[0]; - if(!(borderColor[1] == o.borderColor[1])) - return borderColor[1] < o.borderColor[1]; - if(!(borderColor[2] == o.borderColor[2])) - return borderColor[2] < o.borderColor[2]; - if(!(borderColor[3] == o.borderColor[3])) - return borderColor[3] < o.borderColor[3]; + if(!(borderColor == o.borderColor)) + return borderColor < o.borderColor; if(!(compareFunction == o.compareFunction)) return compareFunction < o.compareFunction; if(!(filter == o.filter)) @@ -346,8 +339,11 @@ struct Sampler AddressMode addressV = AddressMode::Wrap; DOCUMENT("The :class:`AddressMode` in the W direction."); AddressMode addressW = AddressMode::Wrap; - DOCUMENT("The RGBA border color."); - float borderColor[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + DOCUMENT(R"(The RGBA border color. + +:type: Tuple[float,float,float,float] +)"); + rdcfixedarray borderColor = {0.0f, 0.0f, 0.0f, 0.0f}; DOCUMENT("The :class:`CompareFunction` for comparison samplers."); CompareFunction compareFunction = CompareFunction::AlwaysTrue; DOCUMENT(R"(The filtering mode. @@ -641,8 +637,11 @@ struct BlendState )"); rdcarray blends; - DOCUMENT("The constant blend factor to use in blend equations."); - float blendFactor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + DOCUMENT(R"(The constant blend factor to use in blend equations. + +:type: Tuple[float,float,float,float] +)"); + rdcfixedarray blendFactor = {1.0f, 1.0f, 1.0f, 1.0f}; DOCUMENT("The mask determining which samples are written to."); uint32_t sampleMask = ~0U; }; diff --git a/renderdoc/api/replay/d3d12_pipestate.h b/renderdoc/api/replay/d3d12_pipestate.h index e499cce82..ef652a1e1 100644 --- a/renderdoc/api/replay/d3d12_pipestate.h +++ b/renderdoc/api/replay/d3d12_pipestate.h @@ -315,11 +315,10 @@ struct Sampler bool operator==(const Sampler &o) const { return bind == o.bind && tableIndex == o.tableIndex && addressU == o.addressU && - addressV == o.addressV && addressW == o.addressW && borderColor[0] == o.borderColor[0] && - borderColor[1] == o.borderColor[1] && borderColor[2] == o.borderColor[2] && - borderColor[3] == o.borderColor[3] && compareFunction == o.compareFunction && - filter == o.filter && maxAnisotropy == o.maxAnisotropy && maxLOD == o.maxLOD && - minLOD == o.minLOD && mipLODBias == o.mipLODBias; + addressV == o.addressV && addressW == o.addressW && borderColor == o.borderColor && + compareFunction == o.compareFunction && filter == o.filter && + maxAnisotropy == o.maxAnisotropy && maxLOD == o.maxLOD && minLOD == o.minLOD && + mipLODBias == o.mipLODBias; } bool operator<(const Sampler &o) const { @@ -333,14 +332,8 @@ struct Sampler return addressV < o.addressV; if(!(addressW == o.addressW)) return addressW < o.addressW; - if(!(borderColor[0] == o.borderColor[0])) - return borderColor[0] < o.borderColor[0]; - if(!(borderColor[1] == o.borderColor[1])) - return borderColor[1] < o.borderColor[1]; - if(!(borderColor[2] == o.borderColor[2])) - return borderColor[2] < o.borderColor[2]; - if(!(borderColor[3] == o.borderColor[3])) - return borderColor[3] < o.borderColor[3]; + if(!(borderColor == o.borderColor)) + return borderColor < o.borderColor; if(!(compareFunction == o.compareFunction)) return compareFunction < o.compareFunction; if(!(filter == o.filter)) @@ -366,8 +359,11 @@ struct Sampler AddressMode addressV = AddressMode::Wrap; DOCUMENT("The :class:`AddressMode` in the W direction."); AddressMode addressW = AddressMode::Wrap; - DOCUMENT("The RGBA border color."); - float borderColor[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + DOCUMENT(R"(The RGBA border color. + +:type: Tuple[float,float,float,float] +)"); + rdcfixedarray borderColor = {0.0f, 0.0f, 0.0f, 0.0f}; DOCUMENT("The :class:`CompareFunction` for comparison samplers."); CompareFunction compareFunction = CompareFunction::AlwaysTrue; DOCUMENT(R"(The filtering mode. @@ -721,8 +717,11 @@ struct BlendState )"); rdcarray blends; - DOCUMENT("The constant blend factor to use in blend equations."); - float blendFactor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + DOCUMENT(R"(The constant blend factor to use in blend equations. + +:type: Tuple[float,float,float,float] +)"); + rdcfixedarray blendFactor = {1.0f, 1.0f, 1.0f, 1.0f}; }; DOCUMENT("Describes the current state of the output-merger stage of the D3D12 pipeline."); diff --git a/renderdoc/api/replay/data_types.h b/renderdoc/api/replay/data_types.h index 3713e169c..e7ab2a308 100644 --- a/renderdoc/api/replay/data_types.h +++ b/renderdoc/api/replay/data_types.h @@ -1522,7 +1522,7 @@ struct DrawcallDescription eventId = 0; drawcallId = 0; flags = DrawFlags::NoFlags; - markerColor[0] = markerColor[1] = markerColor[2] = markerColor[3] = 0.0f; + markerColor = FloatVector(); numIndices = 0; numInstances = 0; indexOffset = 0; @@ -1565,8 +1565,11 @@ struct DrawcallDescription DOCUMENT("A set of :class:`DrawFlags` properties describing what kind of drawcall this is."); DrawFlags flags; - DOCUMENT("A RGBA color specified by a debug marker call."); - float markerColor[4]; + DOCUMENT(R"(A RGBA color specified by a debug marker call. + +:type: FloatVector +)"); + FloatVector markerColor; DOCUMENT("The number of indices or vertices as appropriate for the drawcall. 0 if not used."); uint32_t numIndices; @@ -1593,14 +1596,23 @@ struct DrawcallDescription )"); uint32_t drawIndex; - DOCUMENT("The 3D number of workgroups to dispatch in a dispatch call."); - uint32_t dispatchDimension[3]; + DOCUMENT(R"(The 3D number of workgroups to dispatch in a dispatch call. - DOCUMENT("The 3D size of each workgroup in threads if the call allows an override, or 0 if not."); - uint32_t dispatchThreadsDimension[3]; +:type: Tuple[int,int,int] +)"); + rdcfixedarray dispatchDimension; - DOCUMENT("The 3D base offset of the workgroup ID if the call allows an override, or 0 if not."); - uint32_t dispatchBase[3]; + DOCUMENT(R"(The 3D size of each workgroup in threads if the call allows an override, or 0 if not. + +:type: Tuple[int,int,int] +)"); + rdcfixedarray dispatchThreadsDimension; + + DOCUMENT(R"(The 3D base offset of the workgroup ID if the call allows an override, or 0 if not. + +:type: Tuple[int,int,int] +)"); + rdcfixedarray dispatchBase; DOCUMENT(R"(The width in bytes of each index. @@ -1651,10 +1663,12 @@ frame. )"); const DrawcallDescription *next; - DOCUMENT(R"(A simple list of the :class:`ResourceId` ids for the color outputs, which can be used + DOCUMENT(R"(An 8-tuple of the :class:`ResourceId` ids for the color outputs, which can be used for very coarse bucketing of drawcalls into similar passes by their outputs. + +:type: Tuple[ResourceId,...] )"); - ResourceId outputs[8]; + rdcfixedarray outputs; DOCUMENT("The resource used for depth output - see :data:`outputs`."); ResourceId depthOut; @@ -1759,15 +1773,14 @@ struct Uuid Uuid &operator=(const Uuid &) = default; DOCUMENT("Compares two ``Uuid`` objects for less-than."); - bool operator<(const Uuid &rhs) const - { - return std::lexicographical_compare(words, words + 4, rhs.words, rhs.words + 4); - } - + bool operator<(const Uuid &rhs) const { return words < rhs.words; } DOCUMENT("Compares two ``Uuid`` objects for equality."); - bool operator==(const Uuid &rhs) const { return ::memcmp(words, rhs.words, sizeof(words)) == 0; } - DOCUMENT("The Uuid bytes as an array of four 32-bit integers.") - uint32_t words[4]; + bool operator==(const Uuid &rhs) const { return words == rhs.words; } + DOCUMENT(R"(The Uuid bytes as a tuple of four 32-bit integers. + +:type: Tuple[int,int,int,int] +)") + rdcfixedarray words; }; DECLARE_REFLECTION_STRUCT(Uuid); @@ -1922,12 +1935,21 @@ DECLARE_REFLECTION_STRUCT(CounterResult); DOCUMENT("The contents of an RGBA pixel."); union PixelValue { - DOCUMENT("The RGBA value interpreted as ``float``."); - float floatValue[4]; - DOCUMENT("The RGBA value interpreted as 32-bit unsigned integer."); - uint32_t uintValue[4]; - DOCUMENT("The RGBA value interpreted as 32-bit signed integer."); - int32_t intValue[4]; + DOCUMENT(R"(The RGBA value interpreted as ``float``. + +:type: Tuple[float, float, float, float] +)"); + rdcfixedarray floatValue; + DOCUMENT(R"(The RGBA value interpreted as 32-bit unsigned integer. + +:type: Tuple[int, int, int, int] +)"); + rdcfixedarray uintValue; + DOCUMENT(R"(The RGBA value interpreted as 32-bit signed integer. + +:type: Tuple[int, int, int, int] +)"); + rdcfixedarray intValue; }; DECLARE_REFLECTION_STRUCT(PixelValue); diff --git a/renderdoc/api/replay/gl_pipestate.h b/renderdoc/api/replay/gl_pipestate.h index 423111fd8..546974b5f 100644 --- a/renderdoc/api/replay/gl_pipestate.h +++ b/renderdoc/api/replay/gl_pipestate.h @@ -215,15 +215,24 @@ struct FixedVertexProcessing FixedVertexProcessing(const FixedVertexProcessing &) = default; FixedVertexProcessing &operator=(const FixedVertexProcessing &) = default; - DOCUMENT("A list of ``float`` giving the default inner level of tessellation."); - float defaultInnerLevel[2] = {0.0f, 0.0f}; - DOCUMENT("A list of ``float`` giving the default outer level of tessellation."); - float defaultOuterLevel[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + DOCUMENT(R"(A tuple of ``float`` giving the default inner level of tessellation. + +:type: Tuple[float,float] +)"); + rdcfixedarray defaultInnerLevel = {0.0f, 0.0f}; + DOCUMENT(R"(A tuple of ``float`` giving the default outer level of tessellation. + +:type: Tuple[float,float,float,float] +)"); + rdcfixedarray defaultOuterLevel = {0.0f, 0.0f, 0.0f, 0.0f}; DOCUMENT("``True`` if primitives should be discarded during rasterization."); bool discard = false; - DOCUMENT("A list of ``bool`` determining which user clipping planes are enabled."); - bool clipPlanes[8] = {false, false, false, false, false, false, false, false}; + DOCUMENT(R"(An 8-tuple of ``bool`` determining which user clipping planes are enabled. + +:type: Tuple[bool,...] +)"); + rdcfixedarray clipPlanes = {false, false, false, false, false, false, false, false}; DOCUMENT(R"(``True`` if the clipping origin should be in the lower left. ``False`` if it's in the upper left. @@ -306,12 +315,10 @@ struct Sampler bool operator==(const Sampler &o) const { return resourceId == o.resourceId && addressS == o.addressS && addressT == o.addressT && - addressR == o.addressR && borderColor[0] == o.borderColor[0] && - borderColor[1] == o.borderColor[1] && borderColor[2] == o.borderColor[2] && - borderColor[3] == o.borderColor[3] && compareFunction == o.compareFunction && - filter == o.filter && seamlessCubeMap == o.seamlessCubeMap && - maxAnisotropy == o.maxAnisotropy && maxLOD == o.maxLOD && minLOD == o.minLOD && - mipLODBias == o.mipLODBias; + addressR == o.addressR && borderColor == o.borderColor && + compareFunction == o.compareFunction && filter == o.filter && + seamlessCubeMap == o.seamlessCubeMap && maxAnisotropy == o.maxAnisotropy && + maxLOD == o.maxLOD && minLOD == o.minLOD && mipLODBias == o.mipLODBias; } bool operator<(const Sampler &o) const { @@ -323,14 +330,8 @@ struct Sampler return addressT < o.addressT; if(!(addressR == o.addressR)) return addressR < o.addressR; - if(!(borderColor[0] == o.borderColor[0])) - return borderColor[0] < o.borderColor[0]; - if(!(borderColor[1] == o.borderColor[1])) - return borderColor[1] < o.borderColor[1]; - if(!(borderColor[2] == o.borderColor[2])) - return borderColor[2] < o.borderColor[2]; - if(!(borderColor[3] == o.borderColor[3])) - return borderColor[3] < o.borderColor[3]; + if(!(borderColor == o.borderColor)) + return borderColor < o.borderColor; if(!(compareFunction == o.compareFunction)) return compareFunction < o.compareFunction; if(!(filter == o.filter)) @@ -355,8 +356,11 @@ struct Sampler AddressMode addressT = AddressMode::Wrap; DOCUMENT("The :class:`AddressMode` in the R direction."); AddressMode addressR = AddressMode::Wrap; - DOCUMENT("The RGBA border color."); - float borderColor[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + DOCUMENT(R"(The RGBA border color. + +:type: Tuple[float,float,float,float] +)"); + rdcfixedarray borderColor = {0.0f, 0.0f, 0.0f, 0.0f}; DOCUMENT("The :class:`CompareFunction` for comparison samplers."); CompareFunction compareFunction = CompareFunction::AlwaysTrue; DOCUMENT(R"(The filtering mode. @@ -484,12 +488,21 @@ struct Feedback DOCUMENT("The :class:`ResourceId` of the transform feedback binding."); ResourceId feedbackResourceId; - DOCUMENT("A list of :class:`ResourceId` with the buffer bindings."); - ResourceId bufferResourceId[4]; - DOCUMENT("A list of ``int`` with the buffer byte offsets."); - uint64_t byteOffset[4] = {0, 0, 0, 0}; - DOCUMENT("A list of ``int`` with the buffer byte sizes."); - uint64_t byteSize[4] = {0, 0, 0, 0}; + DOCUMENT(R"(The buffer bindings. + +:type: Tuple[ResourceId,ResourceId,ResourceId,ResourceId] +)"); + rdcfixedarray bufferResourceId; + DOCUMENT(R"(The buffer byte offsets. + +:type: Tuple[int,int,int,int] +)"); + rdcfixedarray byteOffset = {0, 0, 0, 0}; + DOCUMENT(R"(The buffer byte sizes. + +:type: Tuple[int,int,int,int] +)"); + rdcfixedarray byteSize = {0, 0, 0, 0}; DOCUMENT("``True`` if the transform feedback object is currently active."); bool active = false; DOCUMENT("``True`` if the transform feedback object is currently paused."); @@ -724,8 +737,11 @@ struct BlendState )"); rdcarray blends; - DOCUMENT("The constant blend factor to use in blend equations."); - float blendFactor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + DOCUMENT(R"(The constant blend factor to use in blend equations. + +:type: Tuple[float,float,float,float] +)"); + rdcfixedarray blendFactor = {1.0f, 1.0f, 1.0f, 1.0f}; }; DOCUMENT("Describes the current state of the framebuffer stage of the pipeline."); @@ -805,8 +821,8 @@ struct State DOCUMENT(R"(The tessellation control shader stage. - :type: GLShader - )"); +:type: GLShader +)"); Shader tessControlShader; DOCUMENT(R"(The tessellation evaluation shader stage. diff --git a/renderdoc/api/replay/rdcarray.h b/renderdoc/api/replay/rdcarray.h index 2c6c8df36..b8d84d860 100644 --- a/renderdoc/api/replay/rdcarray.h +++ b/renderdoc/api/replay/rdcarray.h @@ -45,7 +45,7 @@ struct ItemHelper new(first + i) T(); } - static bool equalRange(T *a, T *b, size_t count) + static bool equalRange(const T *a, const T *b, size_t count) { for(size_t i = 0; i < count; i++) if(!(a[i] == b[i])) @@ -54,7 +54,7 @@ struct ItemHelper return true; } - static bool lessthanRange(T *a, T *b, size_t count) + static bool lessthanRange(const T *a, const T *b, size_t count) { for(size_t i = 0; i < count; i++) if(a[i] < b[i]) @@ -68,8 +68,11 @@ template struct ItemHelper { static void initRange(T *first, size_t itemCount) { memset(first, 0, itemCount * sizeof(T)); } - static bool equalRange(T *a, T *b, size_t count) { return !memcmp(a, b, count * sizeof(T)); } - static bool lessthanRange(T *a, T *b, size_t count) + static bool equalRange(const T *a, const T *b, size_t count) + { + return !memcmp(a, b, count * sizeof(T)); + } + static bool lessthanRange(const T *a, const T *b, size_t count) { return memcmp(a, b, count * sizeof(T)) < 0; } @@ -815,6 +818,100 @@ public: #endif }; +// fixed size array, wrapped to be more python-friendly (mapped to an N-tuple) +template +struct rdcfixedarray +{ +public: + ///////////////////////////////////////////////////////////////// + // simple accessors + T &operator[](size_t i) { return elems[i]; } + const T &operator[](size_t i) const { return elems[i]; } + bool operator==(const rdcfixedarray &o) const + { + return ItemHelper::equalRange(elems, o.elems, N); + } + bool operator!=(const rdcfixedarray &o) const { return !(*this == o); } + bool operator<(const rdcfixedarray &o) const + { + return ItemHelper::lessthanRange(elems, o.elems, N); + } + T *data() { return elems; } + const T *data() const { return elems; } + T *begin() { return elems; } + T *end() { return elems + N; } + T &front() { return *elems; } + T &back() { return *(elems + N - 1); } + T &at(size_t idx) { return elems[idx]; } + const T *begin() const { return elems; } + const T *end() const { return elems + N; } + const T &front() const { return *elems; } + const T &back() const { return *(elems + N - 1); } + const T &at(size_t idx) const { return elems[idx]; } + size_t size() const { return N; } + size_t byteSize() const { return N * sizeof(T); } + int32_t count() const { return (int32_t)N; } + // find the first occurrence of an element + int32_t indexOf(const T &el, size_t first = 0, size_t last = ~0U) const + { + for(size_t i = first; i < N && i < last; i++) + { + if(elems[i] == el) + return (int32_t)i; + } + + return -1; + } + + // return true if an element is found + bool contains(const T &el) const { return indexOf(el) != -1; } + rdcfixedarray &operator=(const std::initializer_list &in) + { + size_t i = 0; + for(const T &t : in) + { + elems[i] = t; + i++; + + if(i >= N) + break; + } + + return *this; + } + rdcfixedarray &operator=(const T (&in)[N]) + { + for(size_t i = 0; i < N; i++) + elems[i] = in[i]; + + return *this; + } + rdcfixedarray() = default; + rdcfixedarray(const std::initializer_list &in) + { + static_assert(std::is_trivial::value, + "rdcfixedarray should only be used with POD types like float or uint32_t."); + + // consume all available in the initializer_list, up to N + size_t i = 0; + for(const T &t : in) + { + elems[i] = t; + i++; + + if(i >= N) + break; + } + + // default-initialise any others + for(; i < N; i++) + elems[i] = T(); + } + +private: + T elems[N]; +}; + typedef uint8_t byte; struct bytebuf : public rdcarray diff --git a/renderdoc/api/replay/rdcstr.h b/renderdoc/api/replay/rdcstr.h index d026ddb07..3817df14b 100644 --- a/renderdoc/api/replay/rdcstr.h +++ b/renderdoc/api/replay/rdcstr.h @@ -576,7 +576,7 @@ public: char &front() { ensure_mutable(); - return data()[0]; + return *data(); } char back() const { return *(end() - 1); } char &back() diff --git a/renderdoc/api/replay/shader_types.h b/renderdoc/api/replay/shader_types.h index e8e8fe343..1f79f5e74 100644 --- a/renderdoc/api/replay/shader_types.h +++ b/renderdoc/api/replay/shader_types.h @@ -33,78 +33,6 @@ #include "resourceid.h" #include "stringise.h" -DOCUMENT("A ``float`` 4 component vector.") -struct FloatVecVal -{ - DOCUMENT(""); - FloatVecVal() = default; - FloatVecVal(const FloatVecVal &) = default; - FloatVecVal &operator=(const FloatVecVal &) = default; - - DOCUMENT("The x component."); - float x; - DOCUMENT("The y component."); - float y; - DOCUMENT("The z component."); - float z; - DOCUMENT("The w component."); - float w; -}; - -DOCUMENT("A ``double`` 4 component vector.") -struct DoubleVecVal -{ - DOCUMENT(""); - DoubleVecVal() = default; - DoubleVecVal(const DoubleVecVal &) = default; - DoubleVecVal &operator=(const DoubleVecVal &) = default; - - DOCUMENT("The x component."); - double x; - DOCUMENT("The y component."); - double y; - DOCUMENT("The z component."); - double z; - DOCUMENT("The w component."); - double w; -}; - -DOCUMENT("A 32-bit signed ``int`` 4 component vector.") -struct IntVecVal -{ - DOCUMENT(""); - IntVecVal() = default; - IntVecVal(const IntVecVal &) = default; - IntVecVal &operator=(const IntVecVal &) = default; - - DOCUMENT("The x component."); - int32_t x; - DOCUMENT("The y component."); - int32_t y; - DOCUMENT("The z component."); - int32_t z; - DOCUMENT("The w component."); - int32_t w; -}; - -DOCUMENT("A 32-bit unsigned ``int`` 4 component vector.") -struct UIntVecVal -{ - DOCUMENT(""); - UIntVecVal() = default; - UIntVecVal(const UIntVecVal &) = default; - UIntVecVal &operator=(const UIntVecVal &) = default; - - DOCUMENT("The x component."); - uint32_t x; - DOCUMENT("The y component."); - uint32_t y; - DOCUMENT("The z component."); - uint32_t z; - DOCUMENT("The w component."); - uint32_t w; -}; - DOCUMENT("A 64-bit pointer value with optional type information.") struct PointerVal { @@ -184,58 +112,65 @@ DECLARE_REFLECTION_STRUCT(BindpointIndex); DOCUMENT("A C union that holds 16 values, with each different basic variable type."); union ShaderValue { - DOCUMENT(R"(A convenient subset of :data:`fv` as a named 4 component vector. + DOCUMENT(R"(16-tuple of ``float`` values. -:type: FloatVecVal +:type: Tuple[float,...] )"); - FloatVecVal f; + rdcfixedarray f32v; - DOCUMENT("16-tuple of ``float`` values."); - float fv[16]; + DOCUMENT(R"(16-tuple of 32-bit signed integer values. - DOCUMENT(R"(A convenient subset of :data:`iv` as a named 4 component vector. - -:type: IntVecVal +:type: Tuple[int,...] )"); - IntVecVal i; + rdcfixedarray s32v; - DOCUMENT("16-tuple of 32-bit signed integer values."); - int32_t iv[16]; + DOCUMENT(R"(16-tuple of 32-bit unsigned integer values. - DOCUMENT(R"(A convenient subset of :data:`uv` as a named 4 component vector. - -:type: UIntVecVal +:type: Tuple[int,...] )"); - UIntVecVal u; + rdcfixedarray u32v; - DOCUMENT("16-tuple of 32-bit unsigned integer values."); - uint32_t uv[16]; + DOCUMENT(R"(16-tuple of ``double`` values. - DOCUMENT(R"(A convenient subset of :data:`dv` as a named 4 component vector. - -:type: DoubleVecVal +:type: Tuple[float,...] )"); - DoubleVecVal d; - DOCUMENT("16-tuple of ``double`` values."); - double dv[16]; + rdcfixedarray f64v; - DOCUMENT("16-tuple of 64-bit unsigned integer values."); - uint64_t u64v[16]; + DOCUMENT(R"(16-tuple of 64-bit unsigned integer values. - DOCUMENT("16-tuple of 64-bit signed integer values."); - int64_t s64v[16]; +:type: Tuple[int,...] +)"); + rdcfixedarray u64v; - DOCUMENT("16-tuple of 16-bit unsigned integer values."); - uint16_t u16v[16]; + DOCUMENT(R"(16-tuple of 64-bit signed integer values. - DOCUMENT("16-tuple of 16-bit signed integer values."); - int16_t s16v[16]; +:type: Tuple[int,...] +)"); + rdcfixedarray s64v; - DOCUMENT("16-tuple of 8-bit unsigned integer values."); - uint8_t u8v[16]; + DOCUMENT(R"(16-tuple of 16-bit unsigned integer values. - DOCUMENT("16-tuple of 8-bit signed integer values."); - int8_t s8v[16]; +:type: Tuple[int,...] +)"); + rdcfixedarray u16v; + + DOCUMENT(R"(16-tuple of 16-bit signed integer values. + +:type: Tuple[int,...] +)"); + rdcfixedarray s16v; + + DOCUMENT(R"(16-tuple of 8-bit unsigned integer values. + +:type: Tuple[int,...] +)"); + rdcfixedarray u8v; + + DOCUMENT(R"(16-tuple of 8-bit signed integer values. + +:type: Tuple[int,...] +)"); + rdcfixedarray s8v; }; DOCUMENT(R"(Holds a single named shader variable. It contains either a primitive type (up to a 4x4 @@ -266,10 +201,10 @@ struct ShaderVariable displayAsHex = isStruct = rowMajor = false; memset(&value, 0, sizeof(value)); type = VarType::Float; - value.f.x = x; - value.f.y = y; - value.f.z = z; - value.f.w = w; + value.f32v[0] = x; + value.f32v[1] = y; + value.f32v[2] = z; + value.f32v[3] = w; } ShaderVariable(const rdcstr &n, int x, int y, int z, int w) { @@ -279,10 +214,10 @@ struct ShaderVariable displayAsHex = isStruct = rowMajor = false; memset(&value, 0, sizeof(value)); type = VarType::SInt; - value.i.x = x; - value.i.y = y; - value.i.z = z; - value.i.w = w; + value.s32v[0] = x; + value.s32v[1] = y; + value.s32v[2] = z; + value.s32v[3] = w; } ShaderVariable(const rdcstr &n, uint32_t x, uint32_t y, uint32_t z, uint32_t w) { @@ -292,10 +227,10 @@ struct ShaderVariable displayAsHex = isStruct = rowMajor = false; memset(&value, 0, sizeof(value)); type = VarType::UInt; - value.u.x = x; - value.u.y = y; - value.u.z = z; - value.u.w = w; + value.u32v[0] = x; + value.u32v[1] = y; + value.u32v[2] = z; + value.u32v[3] = w; } bool operator==(const ShaderVariable &o) const { @@ -412,9 +347,9 @@ binding is given by the :data:`type` member. )"); inline void SetBinding(int32_t bindset, int32_t bind, uint32_t arrayIndex) { - value.iv[0] = bindset; - value.iv[1] = bind; - value.uv[2] = arrayIndex; + value.s32v[0] = bindset; + value.s32v[1] = bind; + value.u32v[2] = arrayIndex; } DOCUMENT(R"(Utility function for getting the bindpoint referenced by this variable. @@ -428,7 +363,7 @@ binding is given by the :data:`type` member. )"); inline BindpointIndex GetBinding() const { - return BindpointIndex(value.iv[0], value.iv[1], value.uv[2]); + return BindpointIndex(value.s32v[0], value.s32v[1], value.u32v[2]); } }; @@ -1403,8 +1338,11 @@ struct ShaderReflection )"); bytebuf rawBytes; - DOCUMENT("The 3D dimensions of a compute workgroup, for compute shaders."); - uint32_t dispatchThreadsDimension[3]; + DOCUMENT(R"(The 3D dimensions of a compute workgroup, for compute shaders. + +:type: Tuple[int,int,int] +)"); + rdcfixedarray dispatchThreadsDimension; DOCUMENT(R"(The input signature. diff --git a/renderdoc/api/replay/vk_pipestate.h b/renderdoc/api/replay/vk_pipestate.h index 558028314..85eebae04 100644 --- a/renderdoc/api/replay/vk_pipestate.h +++ b/renderdoc/api/replay/vk_pipestate.h @@ -47,9 +47,7 @@ struct BindingElement addressU == o.addressU && addressV == o.addressV && addressW == o.addressW && mipBias == o.mipBias && maxAnisotropy == o.maxAnisotropy && compareFunction == o.compareFunction && minLOD == o.minLOD && maxLOD == o.maxLOD && - borderColor[0] == o.borderColor[0] && borderColor[1] == o.borderColor[1] && - borderColor[2] == o.borderColor[2] && borderColor[3] == o.borderColor[3] && - unnormalized == o.unnormalized; + borderColor == o.borderColor && unnormalized == o.unnormalized; } bool operator<(const BindingElement &o) const { @@ -99,14 +97,8 @@ struct BindingElement return minLOD < o.minLOD; if(!(maxLOD == o.maxLOD)) return maxLOD < o.maxLOD; - if(!(borderColor[0] == o.borderColor[0])) - return borderColor[0] < o.borderColor[0]; - if(!(borderColor[1] == o.borderColor[1])) - return borderColor[1] < o.borderColor[1]; - if(!(borderColor[2] == o.borderColor[2])) - return borderColor[2] < o.borderColor[2]; - if(!(borderColor[3] == o.borderColor[3])) - return borderColor[3] < o.borderColor[3]; + if(!(borderColor == o.borderColor)) + return borderColor < o.borderColor; if(!(unnormalized == o.unnormalized)) return unnormalized < o.unnormalized; return false; @@ -178,8 +170,11 @@ since single descriptors may only be dynamically skipped by control flow. float minLOD = 0.0f; DOCUMENT("For samplers - the maximum mip level that can be used."); float maxLOD = 0.0f; - DOCUMENT("For samplers - the RGBA border color."); - float borderColor[4]; + DOCUMENT(R"(For samplers - the RGBA border color. + +:type: Tuple[float,float,float,float] +)"); + rdcfixedarray borderColor = {0.0f, 0.0f, 0.0f, 0.0f}; DOCUMENT("For samplers - ``True`` if unnormalized co-ordinates are used in this sampler."); bool unnormalized = false; @@ -879,8 +874,11 @@ struct ColorBlendState )"); rdcarray blends; - DOCUMENT("The constant blend factor to use in blend equations."); - float blendFactor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + DOCUMENT(R"(The constant blend factor to use in blend equations. + +:type: Tuple[float,float,float,float] +)"); + rdcfixedarray blendFactor = {1.0f, 1.0f, 1.0f, 1.0f}; }; DOCUMENT("Describes the pipeline depth-stencil state."); diff --git a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp index 0569721c0..a6c9cf018 100644 --- a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp @@ -64,10 +64,10 @@ bool WrappedID3D11DeviceContext::Serialise_SetMarker(SerialiserType &ser, uint32 byte green = (Color >> 8) & 0xff; byte blue = (Color >> 0) & 0xff; - draw.markerColor[0] = float(red) / 255.0f; - draw.markerColor[1] = float(green) / 255.0f; - draw.markerColor[2] = float(blue) / 255.0f; - draw.markerColor[3] = float(alpha) / 255.0f; + draw.markerColor.x = float(red) / 255.0f; + draw.markerColor.y = float(green) / 255.0f; + draw.markerColor.z = float(blue) / 255.0f; + draw.markerColor.w = float(alpha) / 255.0f; AddEvent(); AddDrawcall(draw, false); @@ -102,10 +102,10 @@ bool WrappedID3D11DeviceContext::Serialise_PushMarker(SerialiserType &ser, uint3 byte green = (Color >> 8) & 0xff; byte blue = (Color >> 0) & 0xff; - draw.markerColor[0] = float(red) / 255.0f; - draw.markerColor[1] = float(green) / 255.0f; - draw.markerColor[2] = float(blue) / 255.0f; - draw.markerColor[3] = float(alpha) / 255.0f; + draw.markerColor.x = float(red) / 255.0f; + draw.markerColor.y = float(green) / 255.0f; + draw.markerColor.z = float(blue) / 255.0f; + draw.markerColor.w = float(alpha) / 255.0f; AddEvent(); AddDrawcall(draw, false); diff --git a/renderdoc/driver/d3d11/d3d11_replay.cpp b/renderdoc/driver/d3d11/d3d11_replay.cpp index 7e1b626d2..53ed3b5be 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.cpp +++ b/renderdoc/driver/d3d11/d3d11_replay.cpp @@ -802,7 +802,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) samp.addressV = MakeAddressMode(desc.AddressV); samp.addressW = MakeAddressMode(desc.AddressW); - memcpy(samp.borderColor, desc.BorderColor, sizeof(FLOAT) * 4); + samp.borderColor = desc.BorderColor; samp.compareFunction = MakeCompareFunc(desc.ComparisonFunc); samp.filter = MakeFilter(desc.Filter); @@ -1400,7 +1400,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) ret.outputMerger.blendState.sampleMask = rs->OM.SampleMask; - memcpy(ret.outputMerger.blendState.blendFactor, rs->OM.BlendFactor, sizeof(FLOAT) * 4); + ret.outputMerger.blendState.blendFactor = rs->OM.BlendFactor; if(rs->OM.BlendState) { @@ -1579,8 +1579,7 @@ rdcarray D3D11Replay::GetPassEvents(uint32_t eventId) { const DrawcallDescription *prev = start->previous; - if(memcmp(start->outputs, prev->outputs, sizeof(start->outputs)) != 0 || - start->depthOut != prev->depthOut) + if(start->outputs != prev->outputs || start->depthOut != prev->depthOut) break; start = prev; diff --git a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp index bf6d192f7..1b45fef98 100644 --- a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp +++ b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp @@ -530,7 +530,7 @@ ShaderVariable D3D11DebugAPIWrapper::GetSampleInfo(DXBCBytecode::OperandType typ ((ID3D11Texture2D *)res)->GetDesc(&desc); // returns 1 for non-multisampled resources - result.value.u.x = RDCMAX(1U, desc.SampleDesc.Count); + result.value.u32v[0] = RDCMAX(1U, desc.SampleDesc.Count); } else { @@ -538,7 +538,7 @@ ShaderVariable D3D11DebugAPIWrapper::GetSampleInfo(DXBCBytecode::OperandType typ { // special behaviour for non-2D (i.e. by definition non-multisampled) textures when // querying the rasterizer, just return 1. - result.value.u.x = 1; + result.value.u32v[0] = 1; } else { @@ -547,7 +547,7 @@ ShaderVariable D3D11DebugAPIWrapper::GetSampleInfo(DXBCBytecode::OperandType typ StringFormat::Fmt("Shader debugging %d: %s\nResource specified is not a 2D texture", m_instruction, opString)); - result.value.u.x = 0; + result.value.u32v[0] = 0; } } @@ -581,7 +581,7 @@ ShaderVariable D3D11DebugAPIWrapper::GetBufferInfo(DXBCBytecode::OperandType typ if(uavDesc.ViewDimension == D3D11_UAV_DIMENSION_BUFFER) { - result.value.u.x = result.value.u.y = result.value.u.z = result.value.u.w = + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = result.value.u32v[3] = uavDesc.Buffer.NumElements; } else @@ -640,12 +640,12 @@ ShaderVariable D3D11DebugAPIWrapper::GetBufferInfo(DXBCBytecode::OperandType typ if(srvDesc.ViewDimension == D3D11_SRV_DIMENSION_BUFFER) { - result.value.u.x = result.value.u.y = result.value.u.z = result.value.u.w = + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = result.value.u32v[3] = srvDesc.Buffer.NumElements; } else if(srvDesc.ViewDimension == D3D11_SRV_DIMENSION_BUFFEREX) { - result.value.u.x = result.value.u.y = result.value.u.z = result.value.u.w = + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = result.value.u32v[3] = srvDesc.BufferEx.NumElements; } else @@ -728,10 +728,10 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t { dim = 1; - result.value.u.x = srvDesc.BufferEx.NumElements; - result.value.u.y = 0; - result.value.u.z = 0; - result.value.u.w = 0; + result.value.u32v[0] = srvDesc.BufferEx.NumElements; + result.value.u32v[1] = 0; + result.value.u32v[2] = 0; + result.value.u32v[3] = 0; break; } case D3D11_SRV_DIMENSION_TEXTURE1D: @@ -748,14 +748,14 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t D3D11_TEXTURE1D_DESC desc; tex->GetDesc(&desc); - result.value.u.x = RDCMAX(1U, desc.Width >> mipLevel); - result.value.u.y = isarray ? srvDesc.Texture1DArray.ArraySize : 0; - result.value.u.z = 0; - result.value.u.w = + result.value.u32v[0] = RDCMAX(1U, desc.Width >> mipLevel); + result.value.u32v[1] = isarray ? srvDesc.Texture1DArray.ArraySize : 0; + result.value.u32v[2] = 0; + result.value.u32v[3] = isarray ? srvDesc.Texture1DArray.MipLevels : srvDesc.Texture1D.MipLevels; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = 0; SAFE_RELEASE(tex); } @@ -775,32 +775,32 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t { D3D11_TEXTURE2D_DESC desc; tex->GetDesc(&desc); - result.value.u.x = RDCMAX(1U, desc.Width >> mipLevel); - result.value.u.y = RDCMAX(1U, desc.Height >> mipLevel); + result.value.u32v[0] = RDCMAX(1U, desc.Width >> mipLevel); + result.value.u32v[1] = RDCMAX(1U, desc.Height >> mipLevel); if(srvDesc.ViewDimension == D3D11_SRV_DIMENSION_TEXTURE2D) { - result.value.u.z = 0; - result.value.u.w = srvDesc.Texture2D.MipLevels; + result.value.u32v[2] = 0; + result.value.u32v[3] = srvDesc.Texture2D.MipLevels; } else if(srvDesc.ViewDimension == D3D11_SRV_DIMENSION_TEXTURE2DARRAY) { - result.value.u.z = srvDesc.Texture2DArray.ArraySize; - result.value.u.w = srvDesc.Texture2DArray.MipLevels; + result.value.u32v[2] = srvDesc.Texture2DArray.ArraySize; + result.value.u32v[3] = srvDesc.Texture2DArray.MipLevels; } else if(srvDesc.ViewDimension == D3D11_SRV_DIMENSION_TEXTURE2DMS) { - result.value.u.z = 0; - result.value.u.w = 1; + result.value.u32v[2] = 0; + result.value.u32v[3] = 1; } else if(srvDesc.ViewDimension == D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY) { - result.value.u.z = srvDesc.Texture2DMSArray.ArraySize; - result.value.u.w = 1; + result.value.u32v[2] = srvDesc.Texture2DMSArray.ArraySize; + result.value.u32v[3] = 1; } - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; SAFE_RELEASE(tex); } @@ -817,13 +817,13 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t { D3D11_TEXTURE3D_DESC desc; tex->GetDesc(&desc); - result.value.u.x = RDCMAX(1U, desc.Width >> mipLevel); - result.value.u.y = RDCMAX(1U, desc.Height >> mipLevel); - result.value.u.z = RDCMAX(1U, desc.Depth >> mipLevel); - result.value.u.w = srvDesc.Texture3D.MipLevels; + result.value.u32v[0] = RDCMAX(1U, desc.Width >> mipLevel); + result.value.u32v[1] = RDCMAX(1U, desc.Height >> mipLevel); + result.value.u32v[2] = RDCMAX(1U, desc.Depth >> mipLevel); + result.value.u32v[3] = srvDesc.Texture3D.MipLevels; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; SAFE_RELEASE(tex); } @@ -843,18 +843,18 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t D3D11_TEXTURE2D_DESC desc; tex->GetDesc(&desc); - result.value.u.x = RDCMAX(1U, desc.Width >> mipLevel); - result.value.u.y = RDCMAX(1U, desc.Height >> mipLevel); + result.value.u32v[0] = RDCMAX(1U, desc.Width >> mipLevel); + result.value.u32v[1] = RDCMAX(1U, desc.Height >> mipLevel); // the spec says "If srcResource is a TextureCubeArray, [...]. dest.z is set to an // undefined value." // but that's stupid, and implementations seem to return the number of cubes - result.value.u.z = isarray ? srvDesc.TextureCubeArray.NumCubes : 0; - result.value.u.w = + result.value.u32v[2] = isarray ? srvDesc.TextureCubeArray.NumCubes : 0; + result.value.u32v[3] = isarray ? srvDesc.TextureCubeArray.MipLevels : srvDesc.TextureCube.MipLevels; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; SAFE_RELEASE(tex); } @@ -910,15 +910,15 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t D3D11_TEXTURE1D_DESC desc; tex->GetDesc(&desc); - result.value.u.x = RDCMAX(1U, desc.Width >> mipLevel); - result.value.u.y = isarray ? uavDesc.Texture1DArray.ArraySize : 0; - result.value.u.z = 0; + result.value.u32v[0] = RDCMAX(1U, desc.Width >> mipLevel); + result.value.u32v[1] = isarray ? uavDesc.Texture1DArray.ArraySize : 0; + result.value.u32v[2] = 0; // spec says "For UAVs (u#), the number of mip levels is always 1." - result.value.u.w = 1; + result.value.u32v[3] = 1; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = 0; SAFE_RELEASE(tex); } @@ -936,19 +936,19 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t { D3D11_TEXTURE2D_DESC desc; tex->GetDesc(&desc); - result.value.u.x = RDCMAX(1U, desc.Width >> mipLevel); - result.value.u.y = RDCMAX(1U, desc.Height >> mipLevel); + result.value.u32v[0] = RDCMAX(1U, desc.Width >> mipLevel); + result.value.u32v[1] = RDCMAX(1U, desc.Height >> mipLevel); if(uavDesc.ViewDimension == D3D11_UAV_DIMENSION_TEXTURE2D) - result.value.u.z = 0; + result.value.u32v[2] = 0; else if(uavDesc.ViewDimension == D3D11_UAV_DIMENSION_TEXTURE2DARRAY) - result.value.u.z = uavDesc.Texture2DArray.ArraySize; + result.value.u32v[2] = uavDesc.Texture2DArray.ArraySize; // spec says "For UAVs (u#), the number of mip levels is always 1." - result.value.u.w = 1; + result.value.u32v[3] = 1; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; SAFE_RELEASE(tex); } @@ -965,15 +965,15 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t { D3D11_TEXTURE3D_DESC desc; tex->GetDesc(&desc); - result.value.u.x = RDCMAX(1U, desc.Width >> mipLevel); - result.value.u.y = RDCMAX(1U, desc.Height >> mipLevel); - result.value.u.z = RDCMAX(1U, desc.Depth >> mipLevel); + result.value.u32v[0] = RDCMAX(1U, desc.Width >> mipLevel); + result.value.u32v[1] = RDCMAX(1U, desc.Height >> mipLevel); + result.value.u32v[2] = RDCMAX(1U, desc.Depth >> mipLevel); // spec says "For UAVs (u#), the number of mip levels is always 1." - result.value.u.w = 1; + result.value.u32v[3] = 1; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; SAFE_RELEASE(tex); } @@ -1174,10 +1174,10 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( for(uint32_t i = 0; i < ddxCalc.columns; i++) { - if(!RDCISFINITE(ddxCalc.value.fv[i])) + if(!RDCISFINITE(ddxCalc.value.f32v[i])) { RDCWARN("NaN or Inf in texlookup"); - ddxCalc.value.fv[i] = 0.0f; + ddxCalc.value.f32v[i] = 0.0f; m_pDevice->AddDebugMessage(MessageCategory::Shaders, MessageSeverity::High, MessageSource::RuntimeWarning, @@ -1185,10 +1185,10 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( "texture lookup ddx - using 0.0 instead", m_instruction, opString)); } - if(!RDCISFINITE(ddyCalc.value.fv[i])) + if(!RDCISFINITE(ddyCalc.value.f32v[i])) { RDCWARN("NaN or Inf in texlookup"); - ddyCalc.value.fv[i] = 0.0f; + ddyCalc.value.f32v[i] = 0.0f; m_pDevice->AddDebugMessage(MessageCategory::Shaders, MessageSeverity::High, MessageSource::RuntimeWarning, @@ -1200,10 +1200,10 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( for(uint32_t i = 0; i < uv.columns; i++) { - if(texcoordType == 0 && !RDCISFINITE(uv.value.fv[i])) + if(texcoordType == 0 && !RDCISFINITE(uv.value.f32v[i])) { RDCWARN("NaN or Inf in texlookup"); - uv.value.fv[i] = 0.0f; + uv.value.f32v[i] = 0.0f; m_pDevice->AddDebugMessage(MessageCategory::Shaders, MessageSeverity::High, MessageSource::RuntimeWarning, @@ -1218,11 +1218,11 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( // because of unions in .value we can pass the float versions and printf will interpret it as // the right type according to formats if(texcoordType == 0) - texcoords = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], uv.value.f.x, - uv.value.f.y, uv.value.f.z, uv.value.f.w); + texcoords = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], uv.value.f32v[0], + uv.value.f32v[1], uv.value.f32v[2], uv.value.f32v[3]); else - texcoords = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], uv.value.i.x, - uv.value.i.y, uv.value.i.z, uv.value.i.w); + texcoords = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], uv.value.s32v[0], + uv.value.s32v[1], uv.value.s32v[2], uv.value.s32v[3]); rdcstr offsets = ""; @@ -1260,11 +1260,13 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( if(opcode == OPCODE_SAMPLE || opcode == OPCODE_SAMPLE_B || opcode == OPCODE_SAMPLE_D) { - rdcstr ddx = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddxCalc.value.f.x, - ddxCalc.value.f.y, ddxCalc.value.f.z, ddxCalc.value.f.w); + rdcstr ddx = + StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddxCalc.value.f32v[0], + ddxCalc.value.f32v[1], ddxCalc.value.f32v[2], ddxCalc.value.f32v[3]); - rdcstr ddy = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddyCalc.value.f.x, - ddyCalc.value.f.y, ddyCalc.value.f.z, ddyCalc.value.f.w); + rdcstr ddy = + StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddyCalc.value.f32v[0], + ddyCalc.value.f32v[1], ddyCalc.value.f32v[2], ddyCalc.value.f32v[3]); sampleProgram = StringFormat::Fmt("%s : register(t0);\n%s : register(s0);\n\n", textureDecl.c_str(), samplerDecl.c_str()); @@ -1294,15 +1296,17 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( vsProgram = "void main(uint id : SV_VertexID, out float4 pos : SV_Position, out " + uvdecl + ") {\n"; - rdcstr uvPlusDDX = StringFormat::Fmt( - formats[texdim + texdimOffs - 1][texcoordType], uv.value.f.x + ddyCalc.value.f.x * 2.0f, - uv.value.f.y + ddyCalc.value.f.y * 2.0f, uv.value.f.z + ddyCalc.value.f.z * 2.0f, - uv.value.f.w + ddyCalc.value.f.w * 2.0f); + rdcstr uvPlusDDX = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], + uv.value.f32v[0] + ddyCalc.value.f32v[0] * 2.0f, + uv.value.f32v[1] + ddyCalc.value.f32v[1] * 2.0f, + uv.value.f32v[2] + ddyCalc.value.f32v[2] * 2.0f, + uv.value.f32v[3] + ddyCalc.value.f32v[3] * 2.0f); - rdcstr uvPlusDDY = StringFormat::Fmt( - formats[texdim + texdimOffs - 1][texcoordType], uv.value.f.x + ddxCalc.value.f.x * 2.0f, - uv.value.f.y + ddxCalc.value.f.y * 2.0f, uv.value.f.z + ddxCalc.value.f.z * 2.0f, - uv.value.f.w + ddxCalc.value.f.w * 2.0f); + rdcstr uvPlusDDY = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], + uv.value.f32v[0] + ddxCalc.value.f32v[0] * 2.0f, + uv.value.f32v[1] + ddxCalc.value.f32v[1] * 2.0f, + uv.value.f32v[2] + ddxCalc.value.f32v[2] * 2.0f, + uv.value.f32v[3] + ddxCalc.value.f32v[3] * 2.0f); vsProgram += "if(id == 0) uv = " + uvPlusDDX + ";\n"; vsProgram += "if(id == 1) uv = " + texcoords + ";\n"; @@ -1553,7 +1557,7 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( ShaderVariable lookupResult("tex", 0.0f, 0.0f, 0.0f, 0.0f); - memcpy(lookupResult.value.iv, mapped.pData, sizeof(uint32_t) * 4); + memcpy(lookupResult.value.u32v.data(), mapped.pData, sizeof(uint32_t) * 4); context->Unmap(copyTex, 0); @@ -1614,7 +1618,7 @@ bool D3D11DebugAPIWrapper::CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcod cdesc.Usage = D3D11_USAGE_DEFAULT; D3D11_SUBRESOURCE_DATA operData = {}; - operData.pSysMem = &input.value.uv[0]; + operData.pSysMem = &input.value.u32v[0]; operData.SysMemPitch = sizeof(Vec4f); operData.SysMemSlicePitch = sizeof(Vec4f); @@ -1696,8 +1700,8 @@ bool D3D11DebugAPIWrapper::CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcod uint32_t *resA = (uint32_t *)mapped.pData; uint32_t *resB = resA + 4; - memcpy(output1.value.uv, resA, sizeof(uint32_t) * 4); - memcpy(output2.value.uv, resB, sizeof(uint32_t) * 4); + memcpy(output1.value.u32v.data(), resA, sizeof(uint32_t) * 4); + memcpy(output2.value.u32v.data(), resB, sizeof(uint32_t) * 4); context->Unmap(copyBuf, 0); @@ -1906,17 +1910,17 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui // more data needed than is provided if(dxbc->GetReflection()->InputSig[i].compCount > fmt.compCount) { - state.inputs[i].value.u.w = 1; + state.inputs[i].value.u32v[3] = 1; if(fmt.compType == CompType::Float) - state.inputs[i].value.f.w = 1.0f; + state.inputs[i].value.f32v[3] = 1.0f; } // interpret resource format types if(fmt.Special()) { - Vec3f *v3 = (Vec3f *)state.inputs[i].value.fv; - Vec4f *v4 = (Vec4f *)state.inputs[i].value.fv; + Vec3f *v3 = (Vec3f *)state.inputs[i].value.f32v.data(); + Vec4f *v4 = (Vec4f *)state.inputs[i].value.f32v.data(); // only pull in all or nothing from these, // if there's only e.g. 3 bytes remaining don't read and unpack some of @@ -1928,11 +1932,12 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui if(srcData == NULL || packedsize > dataSize) { - state.inputs[i].value.u.x = state.inputs[i].value.u.y = state.inputs[i].value.u.z = 0; + state.inputs[i].value.u32v[0] = state.inputs[i].value.u32v[1] = + state.inputs[i].value.u32v[2] = 0; if(fmt.compType == CompType::UInt || fmt.compType == CompType::SInt) - state.inputs[i].value.u.w = 1; + state.inputs[i].value.u32v[3] = 1; else - state.inputs[i].value.f.w = 1.0f; + state.inputs[i].value.f32v[3] = 1.0f; } else if(fmt.type == ResourceFormatType::R5G5B5A1) { @@ -1958,10 +1963,10 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui if(fmt.compType == CompType::UInt) { - state.inputs[i].value.u.z = (packed >> 0) & 0x3ff; - state.inputs[i].value.u.y = (packed >> 10) & 0x3ff; - state.inputs[i].value.u.x = (packed >> 20) & 0x3ff; - state.inputs[i].value.u.w = (packed >> 30) & 0x003; + state.inputs[i].value.u32v[2] = (packed >> 0) & 0x3ff; + state.inputs[i].value.u32v[1] = (packed >> 10) & 0x3ff; + state.inputs[i].value.u32v[0] = (packed >> 20) & 0x3ff; + state.inputs[i].value.u32v[3] = (packed >> 30) & 0x003; } else { @@ -1978,11 +1983,12 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui { if(srcData == NULL || size_t(fmt.compByteWidth * fmt.compCount) > dataSize) { - state.inputs[i].value.u.x = state.inputs[i].value.u.y = state.inputs[i].value.u.z = 0; + state.inputs[i].value.u32v[0] = state.inputs[i].value.u32v[1] = + state.inputs[i].value.u32v[2] = 0; if(fmt.compType == CompType::UInt || fmt.compType == CompType::SInt) - state.inputs[i].value.u.w = 1; + state.inputs[i].value.u32v[3] = 1; else - state.inputs[i].value.f.w = 1.0f; + state.inputs[i].value.f32v[3] = 1.0f; } else { @@ -1993,20 +1999,20 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui byte *src = srcData + c * fmt.compByteWidth; if(fmt.compType == CompType::UInt) - state.inputs[i].value.uv[c] = *src; + state.inputs[i].value.u32v[c] = *src; else if(fmt.compType == CompType::SInt) - state.inputs[i].value.iv[c] = *((int8_t *)src); + state.inputs[i].value.s32v[c] = *((int8_t *)src); else if(fmt.compType == CompType::UNorm || fmt.compType == CompType::UNormSRGB) - state.inputs[i].value.fv[c] = float(*src) / 255.0f; + state.inputs[i].value.f32v[c] = float(*src) / 255.0f; else if(fmt.compType == CompType::SNorm) { signed char *schar = (signed char *)src; // -128 is mapped to -1, then -127 to -127 are mapped to -1 to 1 if(*schar == -128) - state.inputs[i].value.fv[c] = -1.0f; + state.inputs[i].value.f32v[c] = -1.0f; else - state.inputs[i].value.fv[c] = float(*schar) / 127.0f; + state.inputs[i].value.f32v[c] = float(*schar) / 127.0f; } else RDCERR("Unexpected component type"); @@ -2016,22 +2022,22 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui uint16_t *src = (uint16_t *)(srcData + c * fmt.compByteWidth); if(fmt.compType == CompType::Float) - state.inputs[i].value.fv[c] = ConvertFromHalf(*src); + state.inputs[i].value.f32v[c] = ConvertFromHalf(*src); else if(fmt.compType == CompType::UInt) - state.inputs[i].value.uv[c] = *src; + state.inputs[i].value.u32v[c] = *src; else if(fmt.compType == CompType::SInt) - state.inputs[i].value.iv[c] = *((int16_t *)src); + state.inputs[i].value.s32v[c] = *((int16_t *)src); else if(fmt.compType == CompType::UNorm || fmt.compType == CompType::UNormSRGB) - state.inputs[i].value.fv[c] = float(*src) / float(UINT16_MAX); + state.inputs[i].value.f32v[c] = float(*src) / float(UINT16_MAX); else if(fmt.compType == CompType::SNorm) { int16_t *sint = (int16_t *)src; // -32768 is mapped to -1, then -32767 to -32767 are mapped to -1 to 1 if(*sint == -32768) - state.inputs[i].value.fv[c] = -1.0f; + state.inputs[i].value.f32v[c] = -1.0f; else - state.inputs[i].value.fv[c] = float(*sint) / 32767.0f; + state.inputs[i].value.f32v[c] = float(*sint) / 32767.0f; } else RDCERR("Unexpected component type"); @@ -2042,7 +2048,7 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui if(fmt.compType == CompType::Float || fmt.compType == CompType::UInt || fmt.compType == CompType::SInt) - memcpy(&state.inputs[i].value.uv[c], src, 4); + memcpy(&state.inputs[i].value.u32v[c], src, 4); else RDCERR("Unexpected component type"); } @@ -2051,7 +2057,7 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui if(fmt.BGRAOrder()) { RDCASSERT(fmt.compCount == 4); - std::swap(state.inputs[i].value.fv[2], state.inputs[i].value.fv[0]); + std::swap(state.inputs[i].value.f32v[2], state.inputs[i].value.f32v[0]); } } } @@ -2066,20 +2072,20 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui } if(dxbc->GetReflection()->InputSig[i].varType == VarType::Float) - state.inputs[i].value.f.x = state.inputs[i].value.f.y = state.inputs[i].value.f.z = - state.inputs[i].value.f.w = (float)sv_vertid; + state.inputs[i].value.f32v[0] = state.inputs[i].value.f32v[1] = + state.inputs[i].value.f32v[2] = state.inputs[i].value.f32v[3] = (float)sv_vertid; else - state.inputs[i].value.u.x = state.inputs[i].value.u.y = state.inputs[i].value.u.z = - state.inputs[i].value.u.w = sv_vertid; + state.inputs[i].value.u32v[0] = state.inputs[i].value.u32v[1] = + state.inputs[i].value.u32v[2] = state.inputs[i].value.u32v[3] = sv_vertid; } else if(dxbc->GetReflection()->InputSig[i].systemValue == ShaderBuiltin::InstanceIndex) { if(dxbc->GetReflection()->InputSig[i].varType == VarType::Float) - state.inputs[i].value.f.x = state.inputs[i].value.f.y = state.inputs[i].value.f.z = - state.inputs[i].value.f.w = (float)instid; + state.inputs[i].value.f32v[0] = state.inputs[i].value.f32v[1] = + state.inputs[i].value.f32v[2] = state.inputs[i].value.f32v[3] = (float)instid; else - state.inputs[i].value.u.x = state.inputs[i].value.u.y = state.inputs[i].value.u.z = - state.inputs[i].value.u.w = instid; + state.inputs[i].value.u32v[0] = state.inputs[i].value.u32v[1] = + state.inputs[i].value.u32v[2] = state.inputs[i].value.u32v[3] = instid; } else { @@ -2757,7 +2763,7 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, if(!ins.empty() && ins.back().name == dxbc->GetDXBCByteCode()->GetRegisterName(DXBCBytecode::TYPE_INPUT_COVERAGE_MASK, 0)) - ins.back().value.u.x = hit->coverage; + ins.back().value.u32v[0] = hit->coverage; state.semantics.coverage = hit->coverage; state.semantics.primID = hit->primitive; @@ -2790,23 +2796,23 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, if(initialValues[i].sysattribute == ShaderBuiltin::PrimitiveIndex) { - invar.value.u.x = hit->primitive; + invar.value.u32v[0] = hit->primitive; } else if(initialValues[i].sysattribute == ShaderBuiltin::MSAASampleIndex) { - invar.value.u.x = hit->sample; + invar.value.u32v[0] = hit->sample; } else if(initialValues[i].sysattribute == ShaderBuiltin::MSAACoverage) { - invar.value.u.x = hit->coverage; + invar.value.u32v[0] = hit->coverage; } else if(initialValues[i].sysattribute == ShaderBuiltin::IsFrontFace) { - invar.value.u.x = hit->isFrontFace ? ~0U : 0; + invar.value.u32v[0] = hit->isFrontFace ? ~0U : 0; } else { - rawout = &invar.value.iv[initialValues[i].elem]; + rawout = &invar.value.s32v[initialValues[i].elem]; memcpy(rawout, data, initialValues[i].numwords * 4); } @@ -2834,7 +2840,7 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, ShaderVariable var = state.inputs[key.inputRegisterIndex]; // copy over the value into the variable - memcpy(var.value.fv, evalSampleCache, var.columns * sizeof(float)); + memcpy(var.value.f32v.data(), evalSampleCache, var.columns * sizeof(float)); // store in the global cache for each quad. We'll apply derivatives below to adjust for each GlobalState::SampleEvalCacheKey k = key; @@ -2932,27 +2938,27 @@ ShaderDebugTrace *D3D11Replay::DebugThread(uint32_t eventId, const uint32_t grou switch(decl.operand.type) { case TYPE_INPUT_THREAD_GROUP_ID: - memcpy(v.value.uv, state.semantics.GroupID, sizeof(uint32_t) * 3); + memcpy(v.value.u32v.data(), state.semantics.GroupID, sizeof(uint32_t) * 3); v.columns = 3; break; case TYPE_INPUT_THREAD_ID_IN_GROUP: - memcpy(v.value.uv, state.semantics.ThreadID, sizeof(uint32_t) * 3); + memcpy(v.value.u32v.data(), state.semantics.ThreadID, sizeof(uint32_t) * 3); v.columns = 3; break; case TYPE_INPUT_THREAD_ID: - v.value.u.x = + v.value.u32v[0] = state.semantics.GroupID[0] * dxbc->GetReflection()->DispatchThreadsDimension[0] + state.semantics.ThreadID[0]; - v.value.u.y = + v.value.u32v[1] = state.semantics.GroupID[1] * dxbc->GetReflection()->DispatchThreadsDimension[1] + state.semantics.ThreadID[1]; - v.value.u.z = + v.value.u32v[2] = state.semantics.GroupID[2] * dxbc->GetReflection()->DispatchThreadsDimension[2] + state.semantics.ThreadID[2]; v.columns = 3; break; case TYPE_INPUT_THREAD_ID_IN_GROUP_FLATTENED: - v.value.u.x = + v.value.u32v[0] = state.semantics.ThreadID[2] * dxbc->GetReflection()->DispatchThreadsDimension[0] * dxbc->GetReflection()->DispatchThreadsDimension[1] + state.semantics.ThreadID[1] * dxbc->GetReflection()->DispatchThreadsDimension[0] + diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index dd82bd9ad..1a3f975e2 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -1168,7 +1168,7 @@ void D3D12Replay::FillRootElements(const D3D12RenderState::RootSignature &rootSi samp.addressV = MakeAddressMode(sampDesc.AddressV); samp.addressW = MakeAddressMode(sampDesc.AddressW); - memcpy(samp.borderColor, sampDesc.BorderColor, sizeof(FLOAT) * 4); + samp.borderColor = sampDesc.BorderColor; samp.compareFunction = MakeCompareFunc(sampDesc.ComparisonFunc); samp.filter = MakeFilter(sampDesc.Filter); @@ -1525,7 +1525,7 @@ void D3D12Replay::SavePipelineState(uint32_t eventId) if(rs.dsv.GetResResourceId() != ResourceId()) FillResourceView(state.outputMerger.depthTarget, &rs.dsv); - memcpy(state.outputMerger.blendState.blendFactor, rs.blendFactor, sizeof(FLOAT) * 4); + state.outputMerger.blendState.blendFactor = rs.blendFactor; { D3D12_BLEND_DESC &src = pipe->graphics->BlendState; @@ -2659,8 +2659,7 @@ rdcarray D3D12Replay::GetPassEvents(uint32_t eventId) break; // if the outputs changed, we're done - if(memcmp(start->outputs, prev->outputs, sizeof(start->outputs)) != 0 || - start->depthOut != prev->depthOut) + if(start->outputs != prev->outputs || start->depthOut != prev->depthOut) break; start = prev; diff --git a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp index c20e24a07..837d3c8c9 100644 --- a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp +++ b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp @@ -467,7 +467,7 @@ bool D3D12DebugAPIWrapper::CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcod m_pDevice->GetDebugManager()->SetDescriptorHeaps(cmdList, true, false); cmdList->SetPipelineState(m_pDevice->GetDebugManager()->GetMathIntrinsicsPso()); cmdList->SetComputeRootSignature(m_pDevice->GetDebugManager()->GetMathIntrinsicsRootSig()); - cmdList->SetComputeRoot32BitConstants(0, 4, &input.value.uv[0], 0); + cmdList->SetComputeRoot32BitConstants(0, 4, &input.value.u32v[0], 0); cmdList->SetComputeRoot32BitConstants(1, 1, &opcode, 0); cmdList->SetComputeRootUnorderedAccessView(2, pResultBuffer->GetGPUVirtualAddress()); cmdList->Dispatch(1, 1, 1); @@ -489,8 +489,8 @@ bool D3D12DebugAPIWrapper::CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcod m_pDevice->GetDebugManager()->GetBufferData(pResultBuffer, 0, 0, results); RDCASSERT(results.size() >= sizeof(Vec4f) * 2); - memcpy(output1.value.uv, results.data(), sizeof(Vec4f)); - memcpy(output2.value.uv, results.data() + sizeof(Vec4f), sizeof(Vec4f)); + memcpy(output1.value.u32v.data(), results.data(), sizeof(Vec4f)); + memcpy(output2.value.u32v.data(), results.data() + sizeof(Vec4f), sizeof(Vec4f)); return true; } @@ -516,10 +516,10 @@ ShaderVariable D3D12DebugAPIWrapper::GetSampleInfo(DXBCBytecode::OperandType typ ID3D12Resource *pResource = rm->GetCurrentAs(res); D3D12_RESOURCE_DESC resDesc = pResource->GetDesc(); - result.value.u.x = resDesc.SampleDesc.Count; - result.value.u.y = 0; - result.value.u.z = 0; - result.value.u.w = 0; + result.value.u32v[0] = resDesc.SampleDesc.Count; + result.value.u32v[1] = 0; + result.value.u32v[2] = 0; + result.value.u32v[3] = 0; } return result; } @@ -607,10 +607,10 @@ ShaderVariable D3D12DebugAPIWrapper::GetSampleInfo(DXBCBytecode::OperandType typ if(srvDesc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2DMS || srvDesc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY) { - result.value.u.x = resDesc.SampleDesc.Count; - result.value.u.y = 0; - result.value.u.z = 0; - result.value.u.w = 0; + result.value.u32v[0] = resDesc.SampleDesc.Count; + result.value.u32v[1] = 0; + result.value.u32v[2] = 0; + result.value.u32v[3] = 0; } else { @@ -676,7 +676,8 @@ ShaderVariable D3D12DebugAPIWrapper::GetBufferInfo(DXBCBytecode::OperandType typ // Root descriptors are always buffers with each element 32-bit uint32_t numElements = (uint32_t)((resDesc.Width - element.offset) / sizeof(uint32_t)); - result.value.u.x = result.value.u.y = result.value.u.z = result.value.u.w = numElements; + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = + result.value.u32v[3] = numElements; return result; } } @@ -692,7 +693,8 @@ ShaderVariable D3D12DebugAPIWrapper::GetBufferInfo(DXBCBytecode::OperandType typ // Root descriptors are always buffers with each element 32-bit uint32_t numElements = (uint32_t)((resDesc.Width - element.offset) / sizeof(uint32_t)); - result.value.u.x = result.value.u.y = result.value.u.z = result.value.u.w = numElements; + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = + result.value.u32v[3] = numElements; return result; } } @@ -752,8 +754,8 @@ ShaderVariable D3D12DebugAPIWrapper::GetBufferInfo(DXBCBytecode::OperandType typ if(uavDesc.ViewDimension == D3D12_UAV_DIMENSION_BUFFER) { - result.value.u.x = result.value.u.y = result.value.u.z = result.value.u.w = - (uint32_t)uavDesc.Buffer.NumElements; + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = + result.value.u32v[3] = (uint32_t)uavDesc.Buffer.NumElements; } return result; } @@ -769,8 +771,8 @@ ShaderVariable D3D12DebugAPIWrapper::GetBufferInfo(DXBCBytecode::OperandType typ if(srvDesc.ViewDimension == D3D12_SRV_DIMENSION_BUFFER) { - result.value.u.x = result.value.u.y = result.value.u.z = result.value.u.w = - (uint32_t)srvDesc.Buffer.NumElements; + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = + result.value.u32v[3] = (uint32_t)srvDesc.Buffer.NumElements; } return result; } @@ -890,15 +892,15 @@ ShaderVariable D3D12DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t bool isarray = uavDesc.ViewDimension == D3D12_UAV_DIMENSION_TEXTURE1DARRAY; - result.value.u.x = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); - result.value.u.y = isarray ? uavDesc.Texture1DArray.ArraySize : 0; - result.value.u.z = 0; + result.value.u32v[0] = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); + result.value.u32v[1] = isarray ? uavDesc.Texture1DArray.ArraySize : 0; + result.value.u32v[2] = 0; // spec says "For UAVs (u#), the number of mip levels is always 1." - result.value.u.w = 1; + result.value.u32v[3] = 1; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = 0; break; } @@ -907,19 +909,19 @@ ShaderVariable D3D12DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t { dim = 2; - result.value.u.x = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); - result.value.u.y = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); + result.value.u32v[0] = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); + result.value.u32v[1] = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); if(uavDesc.ViewDimension == D3D12_UAV_DIMENSION_TEXTURE2D) - result.value.u.z = 0; + result.value.u32v[2] = 0; else if(uavDesc.ViewDimension == D3D12_UAV_DIMENSION_TEXTURE2DARRAY) - result.value.u.z = uavDesc.Texture2DArray.ArraySize; + result.value.u32v[2] = uavDesc.Texture2DArray.ArraySize; // spec says "For UAVs (u#), the number of mip levels is always 1." - result.value.u.w = 1; + result.value.u32v[3] = 1; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; break; } @@ -927,15 +929,16 @@ ShaderVariable D3D12DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t { dim = 3; - result.value.u.x = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); - result.value.u.y = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); - result.value.u.z = RDCMAX(1U, (uint32_t)(resDesc.DepthOrArraySize >> mipLevel)); + result.value.u32v[0] = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); + result.value.u32v[1] = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); + result.value.u32v[2] = + RDCMAX(1U, (uint32_t)(resDesc.DepthOrArraySize >> mipLevel)); // spec says "For UAVs (u#), the number of mip levels is always 1." - result.value.u.w = 1; + result.value.u32v[3] = 1; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; break; } @@ -967,14 +970,14 @@ ShaderVariable D3D12DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t bool isarray = srvDesc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE1DARRAY; - result.value.u.x = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); - result.value.u.y = isarray ? srvDesc.Texture1DArray.ArraySize : 0; - result.value.u.z = 0; - result.value.u.w = + result.value.u32v[0] = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); + result.value.u32v[1] = isarray ? srvDesc.Texture1DArray.ArraySize : 0; + result.value.u32v[2] = 0; + result.value.u32v[3] = isarray ? srvDesc.Texture1DArray.MipLevels : srvDesc.Texture1D.MipLevels; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = 0; break; } @@ -984,31 +987,31 @@ ShaderVariable D3D12DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t case D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY: { dim = 2; - result.value.u.x = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); - result.value.u.y = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); + result.value.u32v[0] = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); + result.value.u32v[1] = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); if(srvDesc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2D) { - result.value.u.z = 0; - result.value.u.w = srvDesc.Texture2D.MipLevels; + result.value.u32v[2] = 0; + result.value.u32v[3] = srvDesc.Texture2D.MipLevels; } else if(srvDesc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2DARRAY) { - result.value.u.z = srvDesc.Texture2DArray.ArraySize; - result.value.u.w = srvDesc.Texture2DArray.MipLevels; + result.value.u32v[2] = srvDesc.Texture2DArray.ArraySize; + result.value.u32v[3] = srvDesc.Texture2DArray.MipLevels; } else if(srvDesc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2DMS) { - result.value.u.z = 0; - result.value.u.w = 1; + result.value.u32v[2] = 0; + result.value.u32v[3] = 1; } else if(srvDesc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY) { - result.value.u.z = srvDesc.Texture2DMSArray.ArraySize; - result.value.u.w = 1; + result.value.u32v[2] = srvDesc.Texture2DMSArray.ArraySize; + result.value.u32v[3] = 1; } - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; break; } @@ -1016,13 +1019,14 @@ ShaderVariable D3D12DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t { dim = 3; - result.value.u.x = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); - result.value.u.y = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); - result.value.u.z = RDCMAX(1U, (uint32_t)(resDesc.DepthOrArraySize >> mipLevel)); - result.value.u.w = srvDesc.Texture3D.MipLevels; + result.value.u32v[0] = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); + result.value.u32v[1] = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); + result.value.u32v[2] = + RDCMAX(1U, (uint32_t)(resDesc.DepthOrArraySize >> mipLevel)); + result.value.u32v[3] = srvDesc.Texture3D.MipLevels; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; break; } @@ -1035,18 +1039,18 @@ ShaderVariable D3D12DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t bool isarray = srvDesc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURECUBEARRAY; - result.value.u.x = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); - result.value.u.y = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); + result.value.u32v[0] = RDCMAX(1U, (uint32_t)(resDesc.Width >> mipLevel)); + result.value.u32v[1] = RDCMAX(1U, (uint32_t)(resDesc.Height >> mipLevel)); // the spec says "If srcResource is a TextureCubeArray, [...]. dest.z is set // to an undefined value." // but that's stupid, and implementations seem to return the number of cubes - result.value.u.z = isarray ? srvDesc.TextureCubeArray.NumCubes : 0; - result.value.u.w = isarray ? srvDesc.TextureCubeArray.MipLevels - : srvDesc.TextureCube.MipLevels; + result.value.u32v[2] = isarray ? srvDesc.TextureCubeArray.NumCubes : 0; + result.value.u32v[3] = isarray ? srvDesc.TextureCubeArray.MipLevels + : srvDesc.TextureCube.MipLevels; - if(mipLevel >= result.value.u.w) - result.value.u.x = result.value.u.y = result.value.u.z = 0; + if(mipLevel >= result.value.u32v[3]) + result.value.u32v[0] = result.value.u32v[1] = result.value.u32v[2] = 0; break; } @@ -1257,10 +1261,10 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( for(uint32_t i = 0; i < ddxCalc.columns; i++) { - if(!RDCISFINITE(ddxCalc.value.fv[i])) + if(!RDCISFINITE(ddxCalc.value.f32v[i])) { RDCWARN("NaN or Inf in texlookup"); - ddxCalc.value.fv[i] = 0.0f; + ddxCalc.value.f32v[i] = 0.0f; m_pDevice->AddDebugMessage(MessageCategory::Shaders, MessageSeverity::High, MessageSource::RuntimeWarning, @@ -1268,10 +1272,10 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( "texture lookup ddx - using 0.0 instead", m_instruction, opString)); } - if(!RDCISFINITE(ddyCalc.value.fv[i])) + if(!RDCISFINITE(ddyCalc.value.f32v[i])) { RDCWARN("NaN or Inf in texlookup"); - ddyCalc.value.fv[i] = 0.0f; + ddyCalc.value.f32v[i] = 0.0f; m_pDevice->AddDebugMessage(MessageCategory::Shaders, MessageSeverity::High, MessageSource::RuntimeWarning, @@ -1283,10 +1287,10 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( for(uint32_t i = 0; i < uv.columns; i++) { - if(texcoordType == 0 && (!RDCISFINITE(uv.value.fv[i]))) + if(texcoordType == 0 && (!RDCISFINITE(uv.value.f32v[i]))) { RDCWARN("NaN or Inf in texlookup"); - uv.value.fv[i] = 0.0f; + uv.value.f32v[i] = 0.0f; m_pDevice->AddDebugMessage(MessageCategory::Shaders, MessageSeverity::High, MessageSource::RuntimeWarning, @@ -1301,11 +1305,11 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( // because of unions in .value we can pass the float versions and printf will interpret it as // the right type according to formats if(texcoordType == 0) - texcoords = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], uv.value.f.x, - uv.value.f.y, uv.value.f.z, uv.value.f.w); + texcoords = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], uv.value.f32v[0], + uv.value.f32v[1], uv.value.f32v[2], uv.value.f32v[3]); else - texcoords = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], uv.value.i.x, - uv.value.i.y, uv.value.i.z, uv.value.i.w); + texcoords = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], uv.value.s32v[0], + uv.value.s32v[1], uv.value.s32v[2], uv.value.s32v[3]); rdcstr offsets = ""; @@ -1346,11 +1350,13 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( if(opcode == OPCODE_SAMPLE || opcode == OPCODE_SAMPLE_B || opcode == OPCODE_SAMPLE_D) { - rdcstr ddx = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddxCalc.value.f.x, - ddxCalc.value.f.y, ddxCalc.value.f.z, ddxCalc.value.f.w); + rdcstr ddx = + StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddxCalc.value.f32v[0], + ddxCalc.value.f32v[1], ddxCalc.value.f32v[2], ddxCalc.value.f32v[3]); - rdcstr ddy = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddyCalc.value.f.x, - ddyCalc.value.f.y, ddyCalc.value.f.z, ddyCalc.value.f.w); + rdcstr ddy = + StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddyCalc.value.f32v[0], + ddyCalc.value.f32v[1], ddyCalc.value.f32v[2], ddyCalc.value.f32v[3]); sampleSnippet = StringFormat::Fmt("%s : register(%s);\n%s : register(%s);\n\n", textureDecl.c_str(), strResourceBinding.c_str(), @@ -1379,15 +1385,17 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( rdcstr uvswizzle = "xyzw"; uvswizzle.resize(texdim); - rdcstr uvPlusDDX = StringFormat::Fmt( - formats[texdim + texdimOffs - 1][texcoordType], uv.value.f.x + ddyCalc.value.f.x * 2.0f, - uv.value.f.y + ddyCalc.value.f.y * 2.0f, uv.value.f.z + ddyCalc.value.f.z * 2.0f, - uv.value.f.w + ddyCalc.value.f.w * 2.0f); + rdcstr uvPlusDDX = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], + uv.value.f32v[0] + ddyCalc.value.f32v[0] * 2.0f, + uv.value.f32v[1] + ddyCalc.value.f32v[1] * 2.0f, + uv.value.f32v[2] + ddyCalc.value.f32v[2] * 2.0f, + uv.value.f32v[3] + ddyCalc.value.f32v[3] * 2.0f); - rdcstr uvPlusDDY = StringFormat::Fmt( - formats[texdim + texdimOffs - 1][texcoordType], uv.value.f.x + ddxCalc.value.f.x * 2.0f, - uv.value.f.y + ddxCalc.value.f.y * 2.0f, uv.value.f.z + ddxCalc.value.f.z * 2.0f, - uv.value.f.w + ddxCalc.value.f.w * 2.0f); + rdcstr uvPlusDDY = StringFormat::Fmt(formats[texdim + texdimOffs - 1][texcoordType], + uv.value.f32v[0] + ddxCalc.value.f32v[0] * 2.0f, + uv.value.f32v[1] + ddxCalc.value.f32v[1] * 2.0f, + uv.value.f32v[2] + ddxCalc.value.f32v[2] * 2.0f, + uv.value.f32v[3] + ddxCalc.value.f32v[3] * 2.0f); uvSnippet = "float4 uv(uint id) {\n"; uvSnippet += "if(id == 0) return " + uvPlusDDX + ";\n"; @@ -1664,7 +1672,7 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( GetTextureDataParams(), sampleResult); ShaderVariable lookupResult("tex", 0.0f, 0.0f, 0.0f, 0.0f); - memcpy(lookupResult.value.iv, sampleResult.data(), + memcpy(lookupResult.value.u32v.data(), sampleResult.data(), RDCMIN(sampleResult.size(), sizeof(uint32_t) * 4)); output = lookupResult; @@ -1965,17 +1973,17 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui // more data needed than is provided if(dxbc->GetReflection()->InputSig[i].compCount > fmt.compCount) { - state.inputs[i].value.u.w = 1; + state.inputs[i].value.u32v[3] = 1; if(fmt.compType == CompType::Float) - state.inputs[i].value.f.w = 1.0f; + state.inputs[i].value.f32v[3] = 1.0f; } // interpret resource format types if(fmt.Special()) { - Vec3f *v3 = (Vec3f *)state.inputs[i].value.fv; - Vec4f *v4 = (Vec4f *)state.inputs[i].value.fv; + Vec3f *v3 = (Vec3f *)state.inputs[i].value.f32v.data(); + Vec4f *v4 = (Vec4f *)state.inputs[i].value.f32v.data(); // only pull in all or nothing from these, // if there's only e.g. 3 bytes remaining don't read and unpack some of @@ -1987,8 +1995,8 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui if(srcData == NULL || packedsize > dataSize) { - state.inputs[i].value.u.x = state.inputs[i].value.u.y = state.inputs[i].value.u.z = - state.inputs[i].value.u.w = 0; + state.inputs[i].value.u32v[0] = state.inputs[i].value.u32v[1] = + state.inputs[i].value.u32v[2] = state.inputs[i].value.u32v[3] = 0; } else if(fmt.type == ResourceFormatType::R5G5B5A1) { @@ -2014,10 +2022,10 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui if(fmt.compType == CompType::UInt) { - state.inputs[i].value.u.z = (packed >> 0) & 0x3ff; - state.inputs[i].value.u.y = (packed >> 10) & 0x3ff; - state.inputs[i].value.u.x = (packed >> 20) & 0x3ff; - state.inputs[i].value.u.w = (packed >> 30) & 0x003; + state.inputs[i].value.u32v[2] = (packed >> 0) & 0x3ff; + state.inputs[i].value.u32v[1] = (packed >> 10) & 0x3ff; + state.inputs[i].value.u32v[0] = (packed >> 20) & 0x3ff; + state.inputs[i].value.u32v[3] = (packed >> 30) & 0x003; } else { @@ -2036,7 +2044,7 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui { if(srcData == NULL || fmt.compByteWidth > dataSize) { - state.inputs[i].value.uv[c] = 0; + state.inputs[i].value.u32v[c] = 0; continue; } @@ -2047,20 +2055,20 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui byte *src = srcData + c * fmt.compByteWidth; if(fmt.compType == CompType::UInt) - state.inputs[i].value.uv[c] = *src; + state.inputs[i].value.u32v[c] = *src; else if(fmt.compType == CompType::SInt) - state.inputs[i].value.iv[c] = *((int8_t *)src); + state.inputs[i].value.s32v[c] = *((int8_t *)src); else if(fmt.compType == CompType::UNorm || fmt.compType == CompType::UNormSRGB) - state.inputs[i].value.fv[c] = float(*src) / 255.0f; + state.inputs[i].value.f32v[c] = float(*src) / 255.0f; else if(fmt.compType == CompType::SNorm) { signed char *schar = (signed char *)src; // -128 is mapped to -1, then -127 to -127 are mapped to -1 to 1 if(*schar == -128) - state.inputs[i].value.fv[c] = -1.0f; + state.inputs[i].value.f32v[c] = -1.0f; else - state.inputs[i].value.fv[c] = float(*schar) / 127.0f; + state.inputs[i].value.f32v[c] = float(*schar) / 127.0f; } else RDCERR("Unexpected component type"); @@ -2070,22 +2078,22 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui uint16_t *src = (uint16_t *)(srcData + c * fmt.compByteWidth); if(fmt.compType == CompType::Float) - state.inputs[i].value.fv[c] = ConvertFromHalf(*src); + state.inputs[i].value.f32v[c] = ConvertFromHalf(*src); else if(fmt.compType == CompType::UInt) - state.inputs[i].value.uv[c] = *src; + state.inputs[i].value.u32v[c] = *src; else if(fmt.compType == CompType::SInt) - state.inputs[i].value.iv[c] = *((int16_t *)src); + state.inputs[i].value.s32v[c] = *((int16_t *)src); else if(fmt.compType == CompType::UNorm || fmt.compType == CompType::UNormSRGB) - state.inputs[i].value.fv[c] = float(*src) / float(UINT16_MAX); + state.inputs[i].value.f32v[c] = float(*src) / float(UINT16_MAX); else if(fmt.compType == CompType::SNorm) { int16_t *sint = (int16_t *)src; // -32768 is mapped to -1, then -32767 to -32767 are mapped to -1 to 1 if(*sint == -32768) - state.inputs[i].value.fv[c] = -1.0f; + state.inputs[i].value.f32v[c] = -1.0f; else - state.inputs[i].value.fv[c] = float(*sint) / 32767.0f; + state.inputs[i].value.f32v[c] = float(*sint) / 32767.0f; } else RDCERR("Unexpected component type"); @@ -2096,7 +2104,7 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui if(fmt.compType == CompType::Float || fmt.compType == CompType::UInt || fmt.compType == CompType::SInt) - memcpy(&state.inputs[i].value.uv[c], src, 4); + memcpy(&state.inputs[i].value.u32v[c], src, 4); else RDCERR("Unexpected component type"); } @@ -2105,7 +2113,7 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui if(fmt.BGRAOrder()) { RDCASSERT(fmt.compCount == 4); - std::swap(state.inputs[i].value.fv[2], state.inputs[i].value.fv[0]); + std::swap(state.inputs[i].value.f32v[2], state.inputs[i].value.f32v[0]); } } } @@ -2117,20 +2125,20 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui sv_vertid = idx - draw->baseVertex; if(dxbc->GetReflection()->InputSig[i].varType == VarType::Float) - state.inputs[i].value.f.x = state.inputs[i].value.f.y = state.inputs[i].value.f.z = - state.inputs[i].value.f.w = (float)sv_vertid; + state.inputs[i].value.f32v[0] = state.inputs[i].value.f32v[1] = + state.inputs[i].value.f32v[2] = state.inputs[i].value.f32v[3] = (float)sv_vertid; else - state.inputs[i].value.u.x = state.inputs[i].value.u.y = state.inputs[i].value.u.z = - state.inputs[i].value.u.w = sv_vertid; + state.inputs[i].value.u32v[0] = state.inputs[i].value.u32v[1] = + state.inputs[i].value.u32v[2] = state.inputs[i].value.u32v[3] = sv_vertid; } else if(dxbc->GetReflection()->InputSig[i].systemValue == ShaderBuiltin::InstanceIndex) { if(dxbc->GetReflection()->InputSig[i].varType == VarType::Float) - state.inputs[i].value.f.x = state.inputs[i].value.f.y = state.inputs[i].value.f.z = - state.inputs[i].value.f.w = (float)instid; + state.inputs[i].value.f32v[0] = state.inputs[i].value.f32v[1] = + state.inputs[i].value.f32v[2] = state.inputs[i].value.f32v[3] = (float)instid; else - state.inputs[i].value.u.x = state.inputs[i].value.u.y = state.inputs[i].value.u.z = - state.inputs[i].value.u.w = instid; + state.inputs[i].value.u32v[0] = state.inputs[i].value.u32v[1] = + state.inputs[i].value.u32v[2] = state.inputs[i].value.u32v[3] = instid; } else { @@ -2843,7 +2851,7 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, rdcarray &ins = state.inputs; if(!ins.empty() && ins.back().name == "vCoverage") - ins.back().value.u.x = pHit->coverage; + ins.back().value.u32v[0] = pHit->coverage; state.semantics.coverage = pHit->coverage; state.semantics.primID = pHit->primitive; @@ -2874,23 +2882,23 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, if(initialValues[i].sysattribute == ShaderBuiltin::PrimitiveIndex) { - invar.value.u.x = pHit->primitive; + invar.value.u32v[0] = pHit->primitive; } else if(initialValues[i].sysattribute == ShaderBuiltin::MSAASampleIndex) { - invar.value.u.x = pHit->sample; + invar.value.u32v[0] = pHit->sample; } else if(initialValues[i].sysattribute == ShaderBuiltin::MSAACoverage) { - invar.value.u.x = pHit->coverage; + invar.value.u32v[0] = pHit->coverage; } else if(initialValues[i].sysattribute == ShaderBuiltin::IsFrontFace) { - invar.value.u.x = pHit->isFrontFace ? ~0U : 0; + invar.value.u32v[0] = pHit->isFrontFace ? ~0U : 0; } else { - rawout = &invar.value.iv[initialValues[i].elem]; + rawout = &invar.value.s32v[initialValues[i].elem]; memcpy(rawout, data, initialValues[i].numwords * 4); } @@ -2918,7 +2926,7 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, ShaderVariable var = state.inputs[key.inputRegisterIndex]; // copy over the value into the variable - memcpy(var.value.fv, evalSampleCache, var.columns * sizeof(float)); + memcpy(var.value.f32v.data(), evalSampleCache, var.columns * sizeof(float)); // store in the global cache for each quad. We'll apply derivatives below to adjust for each GlobalState::SampleEvalCacheKey k = key; @@ -3024,27 +3032,27 @@ ShaderDebugTrace *D3D12Replay::DebugThread(uint32_t eventId, const uint32_t grou switch(decl.operand.type) { case TYPE_INPUT_THREAD_GROUP_ID: - memcpy(v.value.uv, state.semantics.GroupID, sizeof(uint32_t) * 3); + memcpy(v.value.u32v.data(), state.semantics.GroupID, sizeof(uint32_t) * 3); v.columns = 3; break; case TYPE_INPUT_THREAD_ID_IN_GROUP: - memcpy(v.value.uv, state.semantics.ThreadID, sizeof(uint32_t) * 3); + memcpy(v.value.u32v.data(), state.semantics.ThreadID, sizeof(uint32_t) * 3); v.columns = 3; break; case TYPE_INPUT_THREAD_ID: - v.value.u.x = + v.value.u32v[0] = state.semantics.GroupID[0] * dxbc->GetReflection()->DispatchThreadsDimension[0] + state.semantics.ThreadID[0]; - v.value.u.y = + v.value.u32v[1] = state.semantics.GroupID[1] * dxbc->GetReflection()->DispatchThreadsDimension[1] + state.semantics.ThreadID[1]; - v.value.u.z = + v.value.u32v[2] = state.semantics.GroupID[2] * dxbc->GetReflection()->DispatchThreadsDimension[2] + state.semantics.ThreadID[2]; v.columns = 3; break; case TYPE_INPUT_THREAD_ID_IN_GROUP_FLATTENED: - v.value.u.x = + v.value.u32v[0] = state.semantics.ThreadID[2] * dxbc->GetReflection()->DispatchThreadsDimension[0] * dxbc->GetReflection()->DispatchThreadsDimension[1] + state.semantics.ThreadID[1] * dxbc->GetReflection()->DispatchThreadsDimension[0] + diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index d746cb230..8dedb64be 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -121,8 +121,7 @@ rdcarray GLReplay::GetPassEvents(uint32_t eventId) { const DrawcallDescription *prev = start->previous; - if(memcmp(start->outputs, prev->outputs, sizeof(start->outputs)) != 0 || - start->depthOut != prev->depthOut) + if(start->outputs != prev->outputs || start->depthOut != prev->depthOut) break; start = prev; @@ -855,7 +854,7 @@ void GLReplay::SavePipelineState(uint32_t eventId) RDCEraseEl(pipe.vertexInput.attributes[i].genericValue); drv.glGetVertexAttribfv(i, eGL_CURRENT_VERTEX_ATTRIB, - pipe.vertexInput.attributes[i].genericValue.floatValue); + (GLfloat *)pipe.vertexInput.attributes[i].genericValue.floatValue.data()); ResourceFormat fmt; @@ -968,10 +967,8 @@ void GLReplay::SavePipelineState(uint32_t eventId) pipe.vertexInput.provokingVertexLast = (rs.ProvokingVertex != eGL_FIRST_VERTEX_CONVENTION); - memcpy(pipe.vertexProcessing.defaultInnerLevel, rs.PatchParams.defaultInnerLevel, - sizeof(rs.PatchParams.defaultInnerLevel)); - memcpy(pipe.vertexProcessing.defaultOuterLevel, rs.PatchParams.defaultOuterLevel, - sizeof(rs.PatchParams.defaultOuterLevel)); + pipe.vertexProcessing.defaultInnerLevel = rs.PatchParams.defaultInnerLevel; + pipe.vertexProcessing.defaultOuterLevel = rs.PatchParams.defaultOuterLevel; pipe.vertexProcessing.discard = rs.Enabled[GLRenderState::eEnabled_RasterizerDiscard]; pipe.vertexProcessing.clipOriginLowerLeft = (rs.ClipOrigin != eGL_UPPER_LEFT); @@ -1354,10 +1351,10 @@ void GLReplay::SavePipelineState(uint32_t eventId) { if(samp != 0) drv.glGetSamplerParameterfv(samp, eGL_TEXTURE_BORDER_COLOR, - &pipe.samplers[unit].borderColor[0]); + pipe.samplers[unit].borderColor.data()); else drv.glGetTextureParameterfvEXT(tex, target, eGL_TEXTURE_BORDER_COLOR, - &pipe.samplers[unit].borderColor[0]); + pipe.samplers[unit].borderColor.data()); GLint v; v = 0; @@ -1963,7 +1960,7 @@ void GLReplay::SavePipelineState(uint32_t eventId) pipe.framebuffer.drawFBO.readBuffer = -1; } - memcpy(pipe.framebuffer.blendState.blendFactor, rs.BlendColor, sizeof(rs.BlendColor)); + pipe.framebuffer.blendState.blendFactor = rs.BlendColor; pipe.framebuffer.framebufferSRGB = rs.Enabled[GLRenderState::eEnabled_FramebufferSRGB]; pipe.framebuffer.dither = rs.Enabled[GLRenderState::eEnabled_Dither]; diff --git a/renderdoc/driver/gl/gl_shader_refl.cpp b/renderdoc/driver/gl/gl_shader_refl.cpp index 662b75b15..c6649d670 100644 --- a/renderdoc/driver/gl/gl_shader_refl.cpp +++ b/renderdoc/driver/gl/gl_shader_refl.cpp @@ -1123,7 +1123,8 @@ void MakeShaderReflection(GLenum shadType, GLuint sepProg, ShaderReflection &ref if(shadType == eGL_COMPUTE_SHADER) { - GL.glGetProgramiv(sepProg, eGL_COMPUTE_WORK_GROUP_SIZE, (GLint *)refl.dispatchThreadsDimension); + GL.glGetProgramiv(sepProg, eGL_COMPUTE_WORK_GROUP_SIZE, + (GLint *)refl.dispatchThreadsDimension.data()); } else { diff --git a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp index 657192489..b8513428c 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp @@ -485,15 +485,15 @@ bool OperandSwizzle(const Operation &op, const Operand &oper) void DoubleSet(ShaderVariable &var, const double in[2]) { - var.value.d.x = in[0]; - var.value.d.y = in[1]; + var.value.f64v[0] = in[0]; + var.value.f64v[1] = in[1]; var.type = VarType::Double; } void DoubleGet(const ShaderVariable &var, double out[2]) { - out[0] = var.value.d.x; - out[1] = var.value.d.y; + out[0] = var.value.f64v[0]; + out[1] = var.value.f64v[1]; } void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) @@ -504,14 +504,15 @@ void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) if(fmt.fmt == CompType::UInt) { - u |= (var.value.u.x & 0x3ff) << 0; - u |= (var.value.u.y & 0x3ff) << 10; - u |= (var.value.u.z & 0x3ff) << 20; - u |= (var.value.u.w & 0x3) << 30; + u |= (var.value.u32v[0] & 0x3ff) << 0; + u |= (var.value.u32v[1] & 0x3ff) << 10; + u |= (var.value.u32v[2] & 0x3ff) << 20; + u |= (var.value.u32v[3] & 0x3) << 30; } else if(fmt.fmt == CompType::UNorm) { - u = ConvertToR10G10B10A2(Vec4f(var.value.f.x, var.value.f.y, var.value.f.z, var.value.f.w)); + u = ConvertToR10G10B10A2( + Vec4f(var.value.f32v[0], var.value.f32v[1], var.value.f32v[2], var.value.f32v[3])); } else { @@ -521,7 +522,7 @@ void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) } else if(fmt.byteWidth == 11) { - uint32_t u = ConvertToR11G11B10(Vec3f(var.value.f.x, var.value.f.y, var.value.f.z)); + uint32_t u = ConvertToR11G11B10(Vec3f(var.value.f32v[0], var.value.f32v[1], var.value.f32v[2])); memcpy(d, &u, sizeof(uint32_t)); } else if(fmt.byteWidth == 4) @@ -529,7 +530,7 @@ void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) uint32_t *u = (uint32_t *)d; for(int c = 0; c < fmt.numComps; c++) - u[c] = var.value.uv[c]; + u[c] = var.value.u32v[c]; } else if(fmt.byteWidth == 2) { @@ -538,21 +539,21 @@ void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) uint16_t *u = (uint16_t *)d; for(int c = 0; c < fmt.numComps; c++) - u[c] = ConvertToHalf(var.value.fv[c]); + u[c] = ConvertToHalf(var.value.f32v[c]); } else if(fmt.fmt == CompType::UInt) { uint16_t *u = (uint16_t *)d; for(int c = 0; c < fmt.numComps; c++) - u[c] = var.value.uv[c] & 0xffff; + u[c] = var.value.u32v[c] & 0xffff; } else if(fmt.fmt == CompType::SInt) { int16_t *i = (int16_t *)d; for(int c = 0; c < fmt.numComps; c++) - i[c] = (int16_t)RDCCLAMP(var.value.iv[c], (int32_t)INT16_MIN, (int32_t)INT16_MAX); + i[c] = (int16_t)RDCCLAMP(var.value.s32v[c], (int32_t)INT16_MIN, (int32_t)INT16_MAX); } else if(fmt.fmt == CompType::UNorm || fmt.fmt == CompType::UNormSRGB) { @@ -560,7 +561,7 @@ void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) for(int c = 0; c < fmt.numComps; c++) { - float f = RDCCLAMP(var.value.fv[c], 0.0f, 1.0f) * float(0xffff) + 0.5f; + float f = RDCCLAMP(var.value.f32v[c], 0.0f, 1.0f) * float(0xffff) + 0.5f; u[c] = uint16_t(f); } } @@ -570,7 +571,7 @@ void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) for(int c = 0; c < fmt.numComps; c++) { - float f = RDCCLAMP(var.value.fv[c], -1.0f, 1.0f) * 0x7fff; + float f = RDCCLAMP(var.value.f32v[c], -1.0f, 1.0f) * 0x7fff; if(f < 0.0f) i[c] = int16_t(f - 0.5f); @@ -590,14 +591,14 @@ void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) uint8_t *u = (uint8_t *)d; for(int c = 0; c < fmt.numComps; c++) - u[c] = var.value.uv[c] & 0xff; + u[c] = var.value.u32v[c] & 0xff; } else if(fmt.fmt == CompType::SInt) { int8_t *i = (int8_t *)d; for(int c = 0; c < fmt.numComps; c++) - i[c] = (int8_t)RDCCLAMP(var.value.iv[c], (int32_t)INT8_MIN, (int32_t)INT8_MAX); + i[c] = (int8_t)RDCCLAMP(var.value.s32v[c], (int32_t)INT8_MIN, (int32_t)INT8_MAX); } else if(fmt.fmt == CompType::UNorm || fmt.fmt == CompType::UNormSRGB) { @@ -605,7 +606,7 @@ void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) for(int c = 0; c < fmt.numComps; c++) { - float f = RDCCLAMP(var.value.fv[c], 0.0f, 1.0f) * float(0xff) + 0.5f; + float f = RDCCLAMP(var.value.f32v[c], 0.0f, 1.0f) * float(0xff) + 0.5f; u[c] = uint8_t(f); } } @@ -615,7 +616,7 @@ void TypedUAVStore(GlobalState::ViewFmt &fmt, byte *d, ShaderVariable var) for(int c = 0; c < fmt.numComps; c++) { - float f = RDCCLAMP(var.value.fv[c], -1.0f, 1.0f) * 0x7f; + float f = RDCCLAMP(var.value.f32v[c], -1.0f, 1.0f) * 0x7f; if(f < 0.0f) i[c] = int8_t(f - 0.5f); @@ -641,18 +642,18 @@ ShaderVariable TypedUAVLoad(GlobalState::ViewFmt &fmt, const byte *d) if(fmt.fmt == CompType::UInt) { - result.value.u.x = (u >> 0) & 0x3ff; - result.value.u.y = (u >> 10) & 0x3ff; - result.value.u.z = (u >> 20) & 0x3ff; - result.value.u.w = (u >> 30) & 0x003; + result.value.u32v[0] = (u >> 0) & 0x3ff; + result.value.u32v[1] = (u >> 10) & 0x3ff; + result.value.u32v[2] = (u >> 20) & 0x3ff; + result.value.u32v[3] = (u >> 30) & 0x003; } else if(fmt.fmt == CompType::UNorm) { Vec4f res = ConvertFromR10G10B10A2(u); - result.value.f.x = res.x; - result.value.f.y = res.y; - result.value.f.z = res.z; - result.value.f.w = res.w; + result.value.f32v[0] = res.x; + result.value.f32v[1] = res.y; + result.value.f32v[2] = res.z; + result.value.f32v[3] = res.w; } else { @@ -665,17 +666,17 @@ ShaderVariable TypedUAVLoad(GlobalState::ViewFmt &fmt, const byte *d) memcpy(&u, d, sizeof(uint32_t)); Vec3f res = ConvertFromR11G11B10(u); - result.value.f.x = res.x; - result.value.f.y = res.y; - result.value.f.z = res.z; - result.value.f.w = 1.0f; + result.value.f32v[0] = res.x; + result.value.f32v[1] = res.y; + result.value.f32v[2] = res.z; + result.value.f32v[3] = 1.0f; } else if(fmt.byteWidth == 4) { const uint32_t *u = (const uint32_t *)d; for(int c = 0; c < fmt.numComps; c++) - result.value.uv[c] = u[c]; + result.value.u32v[c] = u[c]; } else if(fmt.byteWidth == 2) { @@ -684,28 +685,28 @@ ShaderVariable TypedUAVLoad(GlobalState::ViewFmt &fmt, const byte *d) const uint16_t *u = (const uint16_t *)d; for(int c = 0; c < fmt.numComps; c++) - result.value.fv[c] = ConvertFromHalf(u[c]); + result.value.f32v[c] = ConvertFromHalf(u[c]); } else if(fmt.fmt == CompType::UInt) { const uint16_t *u = (const uint16_t *)d; for(int c = 0; c < fmt.numComps; c++) - result.value.uv[c] = u[c]; + result.value.u32v[c] = u[c]; } else if(fmt.fmt == CompType::SInt) { const int16_t *in = (const int16_t *)d; for(int c = 0; c < fmt.numComps; c++) - result.value.iv[c] = in[c]; + result.value.s32v[c] = in[c]; } else if(fmt.fmt == CompType::UNorm || fmt.fmt == CompType::UNormSRGB) { const uint16_t *u = (const uint16_t *)d; for(int c = 0; c < fmt.numComps; c++) - result.value.fv[c] = float(u[c]) / float(0xffff); + result.value.f32v[c] = float(u[c]) / float(0xffff); } else if(fmt.fmt == CompType::SNorm) { @@ -715,9 +716,9 @@ ShaderVariable TypedUAVLoad(GlobalState::ViewFmt &fmt, const byte *d) { // -32768 is mapped to -1, then -32767 to -32767 are mapped to -1 to 1 if(in[c] == -32768) - result.value.fv[c] = -1.0f; + result.value.f32v[c] = -1.0f; else - result.value.fv[c] = float(in[c]) / 32767.0f; + result.value.f32v[c] = float(in[c]) / 32767.0f; } } else @@ -732,21 +733,21 @@ ShaderVariable TypedUAVLoad(GlobalState::ViewFmt &fmt, const byte *d) const uint8_t *u = (const uint8_t *)d; for(int c = 0; c < fmt.numComps; c++) - result.value.uv[c] = u[c]; + result.value.u32v[c] = u[c]; } else if(fmt.fmt == CompType::SInt) { const int8_t *in = (const int8_t *)d; for(int c = 0; c < fmt.numComps; c++) - result.value.iv[c] = in[c]; + result.value.s32v[c] = in[c]; } else if(fmt.fmt == CompType::UNorm || fmt.fmt == CompType::UNormSRGB) { const uint8_t *u = (const uint8_t *)d; for(int c = 0; c < fmt.numComps; c++) - result.value.fv[c] = float(u[c]) / float(0xff); + result.value.f32v[c] = float(u[c]) / float(0xff); } else if(fmt.fmt == CompType::SNorm) { @@ -756,9 +757,9 @@ ShaderVariable TypedUAVLoad(GlobalState::ViewFmt &fmt, const byte *d) { // -128 is mapped to -1, then -127 to -127 are mapped to -1 to 1 if(in[c] == -128) - result.value.fv[c] = -1.0f; + result.value.f32v[c] = -1.0f; else - result.value.fv[c] = float(in[c]) / 127.0f; + result.value.f32v[c] = float(in[c]) / 127.0f; } } else @@ -827,13 +828,13 @@ ShaderVariable sat(const ShaderVariable &v, const VarType type) case VarType::SInt: { for(size_t i = 0; i < v.columns; i++) - r.value.iv[i] = v.value.iv[i] < 0 ? 0 : (v.value.iv[i] > 1 ? 1 : v.value.iv[i]); + r.value.s32v[i] = v.value.s32v[i] < 0 ? 0 : (v.value.s32v[i] > 1 ? 1 : v.value.s32v[i]); break; } case VarType::UInt: { for(size_t i = 0; i < v.columns; i++) - r.value.uv[i] = v.value.uv[i] ? 1 : 0; + r.value.u32v[i] = v.value.u32v[i] ? 1 : 0; break; } case VarType::Float: @@ -848,7 +849,7 @@ ShaderVariable sat(const ShaderVariable &v, const VarType type) for(size_t i = 0; i < v.columns; i++) { - r.value.fv[i] = dxbc_min(1.0f, dxbc_max(0.0f, v.value.fv[i])); + r.value.f32v[i] = dxbc_min(1.0f, dxbc_max(0.0f, v.value.f32v[i])); } break; @@ -887,7 +888,7 @@ ShaderVariable abs(const ShaderVariable &v, const VarType type) case VarType::SInt: { for(size_t i = 0; i < v.columns; i++) - r.value.iv[i] = v.value.iv[i] > 0 ? v.value.iv[i] : -v.value.iv[i]; + r.value.s32v[i] = v.value.s32v[i] > 0 ? v.value.s32v[i] : -v.value.s32v[i]; break; } case VarType::UInt: { break; @@ -895,7 +896,7 @@ ShaderVariable abs(const ShaderVariable &v, const VarType type) case VarType::Float: { for(size_t i = 0; i < v.columns; i++) - r.value.fv[i] = v.value.fv[i] > 0 ? v.value.fv[i] : -v.value.fv[i]; + r.value.f32v[i] = v.value.f32v[i] > 0 ? v.value.f32v[i] : -v.value.f32v[i]; break; } case VarType::Double: @@ -932,7 +933,7 @@ ShaderVariable neg(const ShaderVariable &v, const VarType type) case VarType::SInt: { for(size_t i = 0; i < v.columns; i++) - r.value.iv[i] = -v.value.iv[i]; + r.value.s32v[i] = -v.value.s32v[i]; break; } case VarType::UInt: { break; @@ -940,7 +941,7 @@ ShaderVariable neg(const ShaderVariable &v, const VarType type) case VarType::Float: { for(size_t i = 0; i < v.columns; i++) - r.value.fv[i] = -v.value.fv[i]; + r.value.f32v[i] = -v.value.f32v[i]; break; } case VarType::Double: @@ -977,19 +978,19 @@ ShaderVariable mul(const ShaderVariable &a, const ShaderVariable &b, const VarTy case VarType::SInt: { for(size_t i = 0; i < a.columns; i++) - r.value.iv[i] = a.value.iv[i] * b.value.iv[i]; + r.value.s32v[i] = a.value.s32v[i] * b.value.s32v[i]; break; } case VarType::UInt: { for(size_t i = 0; i < a.columns; i++) - r.value.uv[i] = a.value.uv[i] * b.value.uv[i]; + r.value.u32v[i] = a.value.u32v[i] * b.value.u32v[i]; break; } case VarType::Float: { for(size_t i = 0; i < a.columns; i++) - r.value.fv[i] = a.value.fv[i] * b.value.fv[i]; + r.value.f32v[i] = a.value.f32v[i] * b.value.f32v[i]; break; } case VarType::Double: @@ -1027,19 +1028,19 @@ ShaderVariable div(const ShaderVariable &a, const ShaderVariable &b, const VarTy case VarType::SInt: { for(size_t i = 0; i < a.columns; i++) - r.value.iv[i] = a.value.iv[i] / b.value.iv[i]; + r.value.s32v[i] = a.value.s32v[i] / b.value.s32v[i]; break; } case VarType::UInt: { for(size_t i = 0; i < a.columns; i++) - r.value.uv[i] = a.value.uv[i] / b.value.uv[i]; + r.value.u32v[i] = a.value.u32v[i] / b.value.u32v[i]; break; } case VarType::Float: { for(size_t i = 0; i < a.columns; i++) - r.value.fv[i] = a.value.fv[i] / b.value.fv[i]; + r.value.f32v[i] = a.value.f32v[i] / b.value.f32v[i]; break; } case VarType::Double: @@ -1077,19 +1078,19 @@ ShaderVariable add(const ShaderVariable &a, const ShaderVariable &b, const VarTy case VarType::SInt: { for(size_t i = 0; i < a.columns; i++) - r.value.iv[i] = a.value.iv[i] + b.value.iv[i]; + r.value.s32v[i] = a.value.s32v[i] + b.value.s32v[i]; break; } case VarType::UInt: { for(size_t i = 0; i < a.columns; i++) - r.value.uv[i] = a.value.uv[i] + b.value.uv[i]; + r.value.u32v[i] = a.value.u32v[i] + b.value.u32v[i]; break; } case VarType::Float: { for(size_t i = 0; i < a.columns; i++) - r.value.fv[i] = a.value.fv[i] + b.value.fv[i]; + r.value.f32v[i] = a.value.f32v[i] + b.value.f32v[i]; break; } case VarType::Double: @@ -1148,21 +1149,21 @@ ShaderEvents ThreadState::AssignValue(ShaderVariable &dst, uint32_t dstIndex, if(src.type == VarType::Float) { - float ft = src.value.fv[srcIndex]; + float ft = src.value.f32v[srcIndex]; if(!RDCISFINITE(ft)) flags |= ShaderEvents::GeneratedNanOrInf; } else if(src.type == VarType::Double) { - double dt = src.value.dv[srcIndex]; + double dt = src.value.f64v[srcIndex]; if(!RDCISFINITE(dt)) flags |= ShaderEvents::GeneratedNanOrInf; } - dst.value.uv[dstIndex] = src.value.uv[srcIndex]; + dst.value.u32v[dstIndex] = src.value.u32v[srcIndex]; if(flushDenorm && src.type == VarType::Float) - dst.value.fv[dstIndex] = flush_denorm(dst.value.fv[dstIndex]); + dst.value.f32v[dstIndex] = flush_denorm(dst.value.f32v[dstIndex]); return flags; } @@ -1187,7 +1188,7 @@ void ThreadState::SetDst(ShaderDebugState *state, const Operand &dstoper, const { ShaderVariable idx = GetSrc(dstoper.indices[i].operand, op, false); - indices[i] += idx.value.i.x; + indices[i] += idx.value.s32v[0]; } } @@ -1378,7 +1379,7 @@ ShaderVariable ThreadState::GetSrc(const Operand &oper, const Operation &op, boo { ShaderVariable idx = GetSrc(oper.indices[i].operand, op, false); - indices[i] += idx.value.i.x; + indices[i] += idx.value.s32v[0]; } } @@ -1479,7 +1480,7 @@ ShaderVariable ThreadState::GetSrc(const Operand &oper, const Operation &op, boo { for(size_t i = 0; i < s.columns; i++) { - s.value.iv[i] = (int32_t)oper.values[i]; + s.value.s32v[i] = (int32_t)oper.values[i]; } } else @@ -1557,7 +1558,8 @@ ShaderVariable ThreadState::GetSrc(const Operand &oper, const Operation &op, boo // if this Vec4f is entirely in the ICB if(indices[0] <= icb.size() / 4 - 1) { - memcpy(s.value.uv, &icb[indices[0] * 4], sizeof(Vec4f)); + for(size_t i = 0; i < 4; i++) + s.value.u32v[i] = icb[indices[0] * 4 + i]; } else { @@ -1664,10 +1666,10 @@ ShaderVariable ThreadState::GetSrc(const Operand &oper, const Operation &op, boo if(OperandSwizzle(op, oper)) { // perform swizzling - v.value.uv[0] = s.value.uv[oper.comps[0] == 0xff ? 0 : oper.comps[0]]; - v.value.uv[1] = s.value.uv[oper.comps[1] == 0xff ? 1 : oper.comps[1]]; - v.value.uv[2] = s.value.uv[oper.comps[2] == 0xff ? 2 : oper.comps[2]]; - v.value.uv[3] = s.value.uv[oper.comps[3] == 0xff ? 3 : oper.comps[3]]; + v.value.u32v[0] = s.value.u32v[oper.comps[0] == 0xff ? 0 : oper.comps[0]]; + v.value.u32v[1] = s.value.u32v[oper.comps[1] == 0xff ? 1 : oper.comps[1]]; + v.value.u32v[2] = s.value.u32v[oper.comps[2] == 0xff ? 2 : oper.comps[2]]; + v.value.u32v[3] = s.value.u32v[oper.comps[3] == 0xff ? 3 : oper.comps[3]]; if(oper.comps[0] != 0xff && oper.comps[1] == 0xff && oper.comps[2] == 0xff && oper.comps[3] == 0xff) @@ -1693,7 +1695,7 @@ ShaderVariable ThreadState::GetSrc(const Operand &oper, const Operation &op, boo if(OperationFlushing(op.operation) && flushable) { for(int i = 0; i < 4; i++) - v.value.fv[i] = flush_denorm(v.value.fv[i]); + v.value.f32v[i] = flush_denorm(v.value.f32v[i]); } return v; @@ -1735,7 +1737,7 @@ void FlattenSingleVariable(const rdcstr &cbufferName, uint32_t byteOffset, const // if we already have a variable in this slot, just copy the data for this variable and add the // source mapping. // We should not overlap into the next register as that's not allowed. - memcpy(&outvars[outIdx].value.uv[outComp], &v.value.uv[0], sizeof(uint32_t) * v.columns); + memcpy(&outvars[outIdx].value.u32v[outComp], &v.value.u32v[0], sizeof(uint32_t) * v.columns); SourceVariableMapping mapping; mapping.name = basename; @@ -1770,7 +1772,7 @@ void FlattenSingleVariable(const rdcstr &cbufferName, uint32_t byteOffset, const if(v.rowMajor) { for(size_t ri = 0; ri < v.rows; ri++) - memcpy(&outvars[outIdx + ri].value.uv[0], &v.value.uv[ri * v.columns], + memcpy(&outvars[outIdx + ri].value.u32v[0], &v.value.u32v[ri * v.columns], sizeof(uint32_t) * v.columns); } else @@ -1779,7 +1781,7 @@ void FlattenSingleVariable(const rdcstr &cbufferName, uint32_t byteOffset, const // unroll it into vectors. for(size_t ci = 0; ci < v.columns; ci++) for(size_t ri = 0; ri < v.rows; ri++) - outvars[outIdx + ci].value.uv[ri] = v.value.uv[ri * v.columns + ci]; + outvars[outIdx + ci].value.u32v[ri] = v.value.u32v[ri * v.columns + ci]; } SourceVariableMapping mapping; @@ -1976,10 +1978,11 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(size_t i = 0; i < 4; i++) { - if(srcOpers[2].value.uv[i] != 0) + if(srcOpers[2].value.u32v[i] != 0) { - quot.value.uv[i] = srcOpers[1].value.uv[i] / srcOpers[2].value.uv[i]; - rem.value.uv[i] = srcOpers[1].value.uv[i] - (quot.value.uv[i] * srcOpers[2].value.uv[i]); + quot.value.u32v[i] = srcOpers[1].value.u32v[i] / srcOpers[2].value.u32v[i]; + rem.value.u32v[i] = + srcOpers[1].value.u32v[i] - (quot.value.u32v[i] * srcOpers[2].value.u32v[i]); } else { @@ -2004,7 +2007,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(size_t i = 0; i < 4; i++) { - ret.value.uv[i] = BitwiseReverseLSB16(srcOpers[0].value.uv[i]); + ret.value.u32v[i] = BitwiseReverseLSB16(srcOpers[0].value.u32v[i]); } SetDst(state, op.operands[0], op, ret); @@ -2017,7 +2020,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(size_t i = 0; i < 4; i++) { - ret.value.uv[i] = PopCount(srcOpers[0].value.uv[i]); + ret.value.u32v[i] = PopCount(srcOpers[0].value.u32v[i]); } SetDst(state, op.operands[0], op, ret); @@ -2029,16 +2032,16 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(size_t i = 0; i < 4; i++) { - unsigned char found = BitScanReverse((DWORD *)&ret.value.uv[i], srcOpers[0].value.uv[i]); + unsigned char found = BitScanReverse((DWORD *)&ret.value.u32v[i], srcOpers[0].value.u32v[i]); if(found == 0) { - ret.value.uv[i] = ~0U; + ret.value.u32v[i] = ~0U; } else { // firstbit_hi counts index 0 as the MSB, BitScanReverse counts index 0 as the LSB. So we // need to invert - ret.value.uv[i] = 31 - ret.value.uv[i]; + ret.value.u32v[i] = 31 - ret.value.u32v[i]; } } @@ -2051,9 +2054,9 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(size_t i = 0; i < 4; i++) { - unsigned char found = BitScanForward((DWORD *)&ret.value.uv[i], srcOpers[0].value.uv[i]); + unsigned char found = BitScanForward((DWORD *)&ret.value.u32v[i], srcOpers[0].value.u32v[i]); if(found == 0) - ret.value.uv[i] = ~0U; + ret.value.u32v[i] = ~0U; } SetDst(state, op.operands[0], op, ret); @@ -2065,21 +2068,21 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(size_t i = 0; i < 4; i++) { - uint32_t u = srcOpers[0].value.uv[i]; - if(srcOpers[0].value.iv[i] < 0) + uint32_t u = srcOpers[0].value.u32v[i]; + if(srcOpers[0].value.s32v[i] < 0) u = ~u; - unsigned char found = BitScanReverse((DWORD *)&ret.value.uv[i], u); + unsigned char found = BitScanReverse((DWORD *)&ret.value.u32v[i], u); if(found == 0) { - ret.value.uv[i] = ~0U; + ret.value.u32v[i] = ~0U; } else { // firstbit_shi counts index 0 as the MSB, BitScanReverse counts index 0 as the LSB. So we // need to invert - ret.value.uv[i] = 31 - ret.value.uv[i]; + ret.value.u32v[i] = 31 - ret.value.u32v[i]; } } @@ -2096,17 +2099,17 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, { if(op.operation == OPCODE_UMUL) { - uint64_t res = uint64_t(srcOpers[1].value.uv[i]) * uint64_t(srcOpers[2].value.uv[i]); + uint64_t res = uint64_t(srcOpers[1].value.u32v[i]) * uint64_t(srcOpers[2].value.u32v[i]); - hi.value.uv[i] = uint32_t((res >> 32) & 0xffffffff); - lo.value.uv[i] = uint32_t(res & 0xffffffff); + hi.value.u32v[i] = uint32_t((res >> 32) & 0xffffffff); + lo.value.u32v[i] = uint32_t(res & 0xffffffff); } else if(op.operation == OPCODE_IMUL) { - int64_t res = int64_t(srcOpers[1].value.iv[i]) * int64_t(srcOpers[2].value.iv[i]); + int64_t res = int64_t(srcOpers[1].value.s32v[i]) * int64_t(srcOpers[2].value.s32v[i]); - hi.value.uv[i] = uint32_t((res >> 32) & 0xffffffff); - lo.value.uv[i] = uint32_t(res & 0xffffffff); + hi.value.u32v[i] = uint32_t((res >> 32) & 0xffffffff); + lo.value.u32v[i] = uint32_t(res & 0xffffffff); } } @@ -2128,9 +2131,9 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, { uint64_t src[4]; for(int i = 0; i < 4; i++) - src[i] = (uint64_t)srcOpers[1].value.uv[i]; + src[i] = (uint64_t)srcOpers[1].value.u32v[i]; for(int i = 0; i < 4; i++) - src[i] = (uint64_t)srcOpers[2].value.uv[i]; + src[i] = (uint64_t)srcOpers[2].value.u32v[i]; // set the rounded result uint32_t dst[4]; @@ -2155,9 +2158,9 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // add on a 'borrow' bit for(int i = 0; i < 4; i++) - src0[i] = 0x100000000 | (uint64_t)srcOpers[1].value.uv[i]; + src0[i] = 0x100000000 | (uint64_t)srcOpers[1].value.u32v[i]; for(int i = 0; i < 4; i++) - src1[i] = (uint64_t)srcOpers[2].value.uv[i]; + src1[i] = (uint64_t)srcOpers[2].value.u32v[i]; // do the subtract uint64_t result[4]; @@ -2192,12 +2195,12 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, { ShaderVariable dot = mul(srcOpers[0], srcOpers[1], optype); - float sum = dot.value.f.x; - sum += dot.value.f.y; + float sum = dot.value.f32v[0]; + sum += dot.value.f32v[1]; if(op.operation >= OPCODE_DP3) - sum += dot.value.f.z; + sum += dot.value.f32v[2]; if(op.operation >= OPCODE_DP4) - sum += dot.value.f.w; + sum += dot.value.f32v[3]; SetDst(state, op.operands[0], op, ShaderVariable("", sum, sum, sum, sum)); break; @@ -2205,80 +2208,85 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_F16TOF32: { SetDst(state, op.operands[0], op, - ShaderVariable("", flush_denorm(ConvertFromHalf(srcOpers[0].value.u.x & 0xffff)), - flush_denorm(ConvertFromHalf(srcOpers[0].value.u.y & 0xffff)), - flush_denorm(ConvertFromHalf(srcOpers[0].value.u.z & 0xffff)), - flush_denorm(ConvertFromHalf(srcOpers[0].value.u.w & 0xffff)))); + ShaderVariable("", flush_denorm(ConvertFromHalf(srcOpers[0].value.u32v[0] & 0xffff)), + flush_denorm(ConvertFromHalf(srcOpers[0].value.u32v[1] & 0xffff)), + flush_denorm(ConvertFromHalf(srcOpers[0].value.u32v[2] & 0xffff)), + flush_denorm(ConvertFromHalf(srcOpers[0].value.u32v[3] & 0xffff)))); break; } case OPCODE_F32TOF16: { SetDst(state, op.operands[0], op, - ShaderVariable("", (uint32_t)ConvertToHalf(flush_denorm(srcOpers[0].value.f.x)), - (uint32_t)ConvertToHalf(flush_denorm(srcOpers[0].value.f.y)), - (uint32_t)ConvertToHalf(flush_denorm(srcOpers[0].value.f.z)), - (uint32_t)ConvertToHalf(flush_denorm(srcOpers[0].value.f.w)))); + ShaderVariable("", (uint32_t)ConvertToHalf(flush_denorm(srcOpers[0].value.f32v[0])), + (uint32_t)ConvertToHalf(flush_denorm(srcOpers[0].value.f32v[1])), + (uint32_t)ConvertToHalf(flush_denorm(srcOpers[0].value.f32v[2])), + (uint32_t)ConvertToHalf(flush_denorm(srcOpers[0].value.f32v[3])))); break; } case OPCODE_FRC: SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.f.x - floorf(srcOpers[0].value.f.x), - srcOpers[0].value.f.y - floorf(srcOpers[0].value.f.y), - srcOpers[0].value.f.z - floorf(srcOpers[0].value.f.z), - srcOpers[0].value.f.w - floorf(srcOpers[0].value.f.w))); + ShaderVariable("", srcOpers[0].value.f32v[0] - floorf(srcOpers[0].value.f32v[0]), + srcOpers[0].value.f32v[1] - floorf(srcOpers[0].value.f32v[1]), + srcOpers[0].value.f32v[2] - floorf(srcOpers[0].value.f32v[2]), + srcOpers[0].value.f32v[3] - floorf(srcOpers[0].value.f32v[3]))); break; // positive infinity case OPCODE_ROUND_PI: SetDst(state, op.operands[0], op, - ShaderVariable("", ceilf(srcOpers[0].value.f.x), ceilf(srcOpers[0].value.f.y), - ceilf(srcOpers[0].value.f.z), ceilf(srcOpers[0].value.f.w))); + ShaderVariable("", ceilf(srcOpers[0].value.f32v[0]), ceilf(srcOpers[0].value.f32v[1]), + ceilf(srcOpers[0].value.f32v[2]), ceilf(srcOpers[0].value.f32v[3]))); break; // negative infinity case OPCODE_ROUND_NI: SetDst(state, op.operands[0], op, - ShaderVariable("", floorf(srcOpers[0].value.f.x), floorf(srcOpers[0].value.f.y), - floorf(srcOpers[0].value.f.z), floorf(srcOpers[0].value.f.w))); + ShaderVariable("", floorf(srcOpers[0].value.f32v[0]), floorf(srcOpers[0].value.f32v[1]), + floorf(srcOpers[0].value.f32v[2]), floorf(srcOpers[0].value.f32v[3]))); break; // towards zero case OPCODE_ROUND_Z: SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.f.x < 0 ? ceilf(srcOpers[0].value.f.x) - : floorf(srcOpers[0].value.f.x), - srcOpers[0].value.f.y < 0 ? ceilf(srcOpers[0].value.f.y) - : floorf(srcOpers[0].value.f.y), - srcOpers[0].value.f.z < 0 ? ceilf(srcOpers[0].value.f.z) - : floorf(srcOpers[0].value.f.z), - srcOpers[0].value.f.w < 0 ? ceilf(srcOpers[0].value.f.w) - : floorf(srcOpers[0].value.f.w))); + ShaderVariable("", srcOpers[0].value.f32v[0] < 0 ? ceilf(srcOpers[0].value.f32v[0]) + : floorf(srcOpers[0].value.f32v[0]), + srcOpers[0].value.f32v[1] < 0 ? ceilf(srcOpers[0].value.f32v[1]) + : floorf(srcOpers[0].value.f32v[1]), + srcOpers[0].value.f32v[2] < 0 ? ceilf(srcOpers[0].value.f32v[2]) + : floorf(srcOpers[0].value.f32v[2]), + srcOpers[0].value.f32v[3] < 0 ? ceilf(srcOpers[0].value.f32v[3]) + : floorf(srcOpers[0].value.f32v[3]))); break; // to nearest even int (banker's rounding) case OPCODE_ROUND_NE: - SetDst(state, op.operands[0], op, - ShaderVariable("", round_ne(srcOpers[0].value.f.x), round_ne(srcOpers[0].value.f.y), - round_ne(srcOpers[0].value.f.z), round_ne(srcOpers[0].value.f.w))); + SetDst(state, op.operands[0], op, ShaderVariable("", round_ne(srcOpers[0].value.f32v[0]), + round_ne(srcOpers[0].value.f32v[1]), + round_ne(srcOpers[0].value.f32v[2]), + round_ne(srcOpers[0].value.f32v[3]))); break; case OPCODE_INEG: SetDst(state, op.operands[0], op, neg(srcOpers[0], optype)); break; case OPCODE_IMIN: - SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.i.x < srcOpers[1].value.i.x ? srcOpers[0].value.i.x - : srcOpers[1].value.i.x, - srcOpers[0].value.i.y < srcOpers[1].value.i.y ? srcOpers[0].value.i.y - : srcOpers[1].value.i.y, - srcOpers[0].value.i.z < srcOpers[1].value.i.z ? srcOpers[0].value.i.z - : srcOpers[1].value.i.z, - srcOpers[0].value.i.w < srcOpers[1].value.i.w ? srcOpers[0].value.i.w - : srcOpers[1].value.i.w)); + SetDst( + state, op.operands[0], op, + ShaderVariable( + "", srcOpers[0].value.s32v[0] < srcOpers[1].value.s32v[0] ? srcOpers[0].value.s32v[0] + : srcOpers[1].value.s32v[0], + srcOpers[0].value.s32v[1] < srcOpers[1].value.s32v[1] ? srcOpers[0].value.s32v[1] + : srcOpers[1].value.s32v[1], + srcOpers[0].value.s32v[2] < srcOpers[1].value.s32v[2] ? srcOpers[0].value.s32v[2] + : srcOpers[1].value.s32v[2], + srcOpers[0].value.s32v[3] < srcOpers[1].value.s32v[3] ? srcOpers[0].value.s32v[3] + : srcOpers[1].value.s32v[3])); break; case OPCODE_UMIN: - SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.u.x < srcOpers[1].value.u.x ? srcOpers[0].value.u.x - : srcOpers[1].value.u.x, - srcOpers[0].value.u.y < srcOpers[1].value.u.y ? srcOpers[0].value.u.y - : srcOpers[1].value.u.y, - srcOpers[0].value.u.z < srcOpers[1].value.u.z ? srcOpers[0].value.u.z - : srcOpers[1].value.u.z, - srcOpers[0].value.u.w < srcOpers[1].value.u.w ? srcOpers[0].value.u.w - : srcOpers[1].value.u.w)); + SetDst( + state, op.operands[0], op, + ShaderVariable( + "", srcOpers[0].value.u32v[0] < srcOpers[1].value.u32v[0] ? srcOpers[0].value.u32v[0] + : srcOpers[1].value.u32v[0], + srcOpers[0].value.u32v[1] < srcOpers[1].value.u32v[1] ? srcOpers[0].value.u32v[1] + : srcOpers[1].value.u32v[1], + srcOpers[0].value.u32v[2] < srcOpers[1].value.u32v[2] ? srcOpers[0].value.u32v[2] + : srcOpers[1].value.u32v[2], + srcOpers[0].value.u32v[3] < srcOpers[1].value.u32v[3] ? srcOpers[0].value.u32v[3] + : srcOpers[1].value.u32v[3])); break; case OPCODE_DMIN: { @@ -2298,34 +2306,36 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } case OPCODE_MIN: SetDst(state, op.operands[0], op, - ShaderVariable("", dxbc_min(srcOpers[0].value.f.x, srcOpers[1].value.f.x), - dxbc_min(srcOpers[0].value.f.y, srcOpers[1].value.f.y), - dxbc_min(srcOpers[0].value.f.z, srcOpers[1].value.f.z), - dxbc_min(srcOpers[0].value.f.w, srcOpers[1].value.f.w))); + ShaderVariable("", dxbc_min(srcOpers[0].value.f32v[0], srcOpers[1].value.f32v[0]), + dxbc_min(srcOpers[0].value.f32v[1], srcOpers[1].value.f32v[1]), + dxbc_min(srcOpers[0].value.f32v[2], srcOpers[1].value.f32v[2]), + dxbc_min(srcOpers[0].value.f32v[3], srcOpers[1].value.f32v[3]))); break; case OPCODE_UMAX: SetDst( state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.u.x >= srcOpers[1].value.u.x ? srcOpers[0].value.u.x - : srcOpers[1].value.u.x, - srcOpers[0].value.u.y >= srcOpers[1].value.u.y ? srcOpers[0].value.u.y - : srcOpers[1].value.u.y, - srcOpers[0].value.u.z >= srcOpers[1].value.u.z ? srcOpers[0].value.u.z - : srcOpers[1].value.u.z, - srcOpers[0].value.u.w >= srcOpers[1].value.u.w ? srcOpers[0].value.u.w - : srcOpers[1].value.u.w)); + ShaderVariable( + "", srcOpers[0].value.u32v[0] >= srcOpers[1].value.u32v[0] ? srcOpers[0].value.u32v[0] + : srcOpers[1].value.u32v[0], + srcOpers[0].value.u32v[1] >= srcOpers[1].value.u32v[1] ? srcOpers[0].value.u32v[1] + : srcOpers[1].value.u32v[1], + srcOpers[0].value.u32v[2] >= srcOpers[1].value.u32v[2] ? srcOpers[0].value.u32v[2] + : srcOpers[1].value.u32v[2], + srcOpers[0].value.u32v[3] >= srcOpers[1].value.u32v[3] ? srcOpers[0].value.u32v[3] + : srcOpers[1].value.u32v[3])); break; case OPCODE_IMAX: SetDst( state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.i.x >= srcOpers[1].value.i.x ? srcOpers[0].value.i.x - : srcOpers[1].value.i.x, - srcOpers[0].value.i.y >= srcOpers[1].value.i.y ? srcOpers[0].value.i.y - : srcOpers[1].value.i.y, - srcOpers[0].value.i.z >= srcOpers[1].value.i.z ? srcOpers[0].value.i.z - : srcOpers[1].value.i.z, - srcOpers[0].value.i.w >= srcOpers[1].value.i.w ? srcOpers[0].value.i.w - : srcOpers[1].value.i.w)); + ShaderVariable( + "", srcOpers[0].value.s32v[0] >= srcOpers[1].value.s32v[0] ? srcOpers[0].value.s32v[0] + : srcOpers[1].value.s32v[0], + srcOpers[0].value.s32v[1] >= srcOpers[1].value.s32v[1] ? srcOpers[0].value.s32v[1] + : srcOpers[1].value.s32v[1], + srcOpers[0].value.s32v[2] >= srcOpers[1].value.s32v[2] ? srcOpers[0].value.s32v[2] + : srcOpers[1].value.s32v[2], + srcOpers[0].value.s32v[3] >= srcOpers[1].value.s32v[3] ? srcOpers[0].value.s32v[3] + : srcOpers[1].value.s32v[3])); break; case OPCODE_DMAX: { @@ -2345,15 +2355,15 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } case OPCODE_MAX: SetDst(state, op.operands[0], op, - ShaderVariable("", dxbc_max(srcOpers[0].value.f.x, srcOpers[1].value.f.x), - dxbc_max(srcOpers[0].value.f.y, srcOpers[1].value.f.y), - dxbc_max(srcOpers[0].value.f.z, srcOpers[1].value.f.z), - dxbc_max(srcOpers[0].value.f.w, srcOpers[1].value.f.w))); + ShaderVariable("", dxbc_max(srcOpers[0].value.f32v[0], srcOpers[1].value.f32v[0]), + dxbc_max(srcOpers[0].value.f32v[1], srcOpers[1].value.f32v[1]), + dxbc_max(srcOpers[0].value.f32v[2], srcOpers[1].value.f32v[2]), + dxbc_max(srcOpers[0].value.f32v[3], srcOpers[1].value.f32v[3]))); break; case OPCODE_SQRT: SetDst(state, op.operands[0], op, - ShaderVariable("", sqrtf(srcOpers[0].value.f.x), sqrtf(srcOpers[0].value.f.y), - sqrtf(srcOpers[0].value.f.z), sqrtf(srcOpers[0].value.f.w))); + ShaderVariable("", sqrtf(srcOpers[0].value.f32v[0]), sqrtf(srcOpers[0].value.f32v[1]), + sqrtf(srcOpers[0].value.f32v[2]), sqrtf(srcOpers[0].value.f32v[3]))); break; case OPCODE_DRCP: { @@ -2372,30 +2382,32 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_IBFE: { // bottom 5 bits - ShaderVariable width( - "", (int32_t)(srcOpers[0].value.i.x & 0x1f), (int32_t)(srcOpers[0].value.i.y & 0x1f), - (int32_t)(srcOpers[0].value.i.z & 0x1f), (int32_t)(srcOpers[0].value.i.w & 0x1f)); - ShaderVariable offset( - "", (int32_t)(srcOpers[1].value.i.x & 0x1f), (int32_t)(srcOpers[1].value.i.y & 0x1f), - (int32_t)(srcOpers[1].value.i.z & 0x1f), (int32_t)(srcOpers[1].value.i.w & 0x1f)); + ShaderVariable width("", (int32_t)(srcOpers[0].value.s32v[0] & 0x1f), + (int32_t)(srcOpers[0].value.s32v[1] & 0x1f), + (int32_t)(srcOpers[0].value.s32v[2] & 0x1f), + (int32_t)(srcOpers[0].value.s32v[3] & 0x1f)); + ShaderVariable offset("", (int32_t)(srcOpers[1].value.s32v[0] & 0x1f), + (int32_t)(srcOpers[1].value.s32v[1] & 0x1f), + (int32_t)(srcOpers[1].value.s32v[2] & 0x1f), + (int32_t)(srcOpers[1].value.s32v[3] & 0x1f)); ShaderVariable dest("", (int32_t)0, (int32_t)0, (int32_t)0, (int32_t)0); for(int comp = 0; comp < 4; comp++) { - if(width.value.iv[comp] == 0) + if(width.value.s32v[comp] == 0) { - dest.value.iv[comp] = 0; + dest.value.s32v[comp] = 0; } - else if(width.value.iv[comp] + offset.value.iv[comp] < 32) + else if(width.value.s32v[comp] + offset.value.s32v[comp] < 32) { - dest.value.iv[comp] = srcOpers[2].value.iv[comp] - << (32 - (width.value.iv[comp] + offset.value.iv[comp])); - dest.value.iv[comp] = dest.value.iv[comp] >> (32 - width.value.iv[comp]); + dest.value.s32v[comp] = srcOpers[2].value.s32v[comp] + << (32 - (width.value.s32v[comp] + offset.value.s32v[comp])); + dest.value.s32v[comp] = dest.value.s32v[comp] >> (32 - width.value.s32v[comp]); } else { - dest.value.iv[comp] = srcOpers[2].value.iv[comp] >> offset.value.iv[comp]; + dest.value.s32v[comp] = srcOpers[2].value.s32v[comp] >> offset.value.s32v[comp]; } } @@ -2405,30 +2417,32 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_UBFE: { // bottom 5 bits - ShaderVariable width( - "", (uint32_t)(srcOpers[0].value.u.x & 0x1f), (uint32_t)(srcOpers[0].value.u.y & 0x1f), - (uint32_t)(srcOpers[0].value.u.z & 0x1f), (uint32_t)(srcOpers[0].value.u.w & 0x1f)); - ShaderVariable offset( - "", (uint32_t)(srcOpers[1].value.u.x & 0x1f), (uint32_t)(srcOpers[1].value.u.y & 0x1f), - (uint32_t)(srcOpers[1].value.u.z & 0x1f), (uint32_t)(srcOpers[1].value.u.w & 0x1f)); + ShaderVariable width("", (uint32_t)(srcOpers[0].value.u32v[0] & 0x1f), + (uint32_t)(srcOpers[0].value.u32v[1] & 0x1f), + (uint32_t)(srcOpers[0].value.u32v[2] & 0x1f), + (uint32_t)(srcOpers[0].value.u32v[3] & 0x1f)); + ShaderVariable offset("", (uint32_t)(srcOpers[1].value.u32v[0] & 0x1f), + (uint32_t)(srcOpers[1].value.u32v[1] & 0x1f), + (uint32_t)(srcOpers[1].value.u32v[2] & 0x1f), + (uint32_t)(srcOpers[1].value.u32v[3] & 0x1f)); ShaderVariable dest("", (uint32_t)0, (uint32_t)0, (uint32_t)0, (uint32_t)0); for(int comp = 0; comp < 4; comp++) { - if(width.value.uv[comp] == 0) + if(width.value.u32v[comp] == 0) { - dest.value.uv[comp] = 0; + dest.value.u32v[comp] = 0; } - else if(width.value.uv[comp] + offset.value.uv[comp] < 32) + else if(width.value.u32v[comp] + offset.value.u32v[comp] < 32) { - dest.value.uv[comp] = srcOpers[2].value.uv[comp] - << (32 - (width.value.uv[comp] + offset.value.uv[comp])); - dest.value.uv[comp] = dest.value.uv[comp] >> (32 - width.value.uv[comp]); + dest.value.u32v[comp] = srcOpers[2].value.u32v[comp] + << (32 - (width.value.u32v[comp] + offset.value.u32v[comp])); + dest.value.u32v[comp] = dest.value.u32v[comp] >> (32 - width.value.u32v[comp]); } else { - dest.value.uv[comp] = srcOpers[2].value.uv[comp] >> offset.value.uv[comp]; + dest.value.u32v[comp] = srcOpers[2].value.u32v[comp] >> offset.value.u32v[comp]; } } @@ -2438,21 +2452,24 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_BFI: { // bottom 5 bits - ShaderVariable width( - "", (uint32_t)(srcOpers[0].value.u.x & 0x1f), (uint32_t)(srcOpers[0].value.u.y & 0x1f), - (uint32_t)(srcOpers[0].value.u.z & 0x1f), (uint32_t)(srcOpers[0].value.u.w & 0x1f)); - ShaderVariable offset( - "", (uint32_t)(srcOpers[1].value.u.x & 0x1f), (uint32_t)(srcOpers[1].value.u.y & 0x1f), - (uint32_t)(srcOpers[1].value.u.z & 0x1f), (uint32_t)(srcOpers[1].value.u.w & 0x1f)); + ShaderVariable width("", (uint32_t)(srcOpers[0].value.u32v[0] & 0x1f), + (uint32_t)(srcOpers[0].value.u32v[1] & 0x1f), + (uint32_t)(srcOpers[0].value.u32v[2] & 0x1f), + (uint32_t)(srcOpers[0].value.u32v[3] & 0x1f)); + ShaderVariable offset("", (uint32_t)(srcOpers[1].value.u32v[0] & 0x1f), + (uint32_t)(srcOpers[1].value.u32v[1] & 0x1f), + (uint32_t)(srcOpers[1].value.u32v[2] & 0x1f), + (uint32_t)(srcOpers[1].value.u32v[3] & 0x1f)); ShaderVariable dest("", (uint32_t)0, (uint32_t)0, (uint32_t)0, (uint32_t)0); for(int comp = 0; comp < 4; comp++) { - uint32_t bitmask = (((1 << width.value.uv[comp]) - 1) << offset.value.uv[comp]) & 0xffffffff; - dest.value.uv[comp] = - (uint32_t)(((srcOpers[2].value.uv[comp] << offset.value.uv[comp]) & bitmask) | - (srcOpers[3].value.uv[comp] & ~bitmask)); + uint32_t bitmask = + (((1 << width.value.u32v[comp]) - 1) << offset.value.u32v[comp]) & 0xffffffff; + dest.value.u32v[comp] = + (uint32_t)(((srcOpers[2].value.u32v[comp] << offset.value.u32v[comp]) & bitmask) | + (srcOpers[3].value.u32v[comp] & ~bitmask)); } SetDst(state, op.operands[0], op, dest); @@ -2461,8 +2478,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_ISHL: { uint32_t shifts[] = { - srcOpers[1].value.u.x & 0x1f, srcOpers[1].value.u.y & 0x1f, srcOpers[1].value.u.z & 0x1f, - srcOpers[1].value.u.w & 0x1f, + srcOpers[1].value.u32v[0] & 0x1f, srcOpers[1].value.u32v[1] & 0x1f, + srcOpers[1].value.u32v[2] & 0x1f, srcOpers[1].value.u32v[3] & 0x1f, }; // if we were only given a single component, it's the form that shifts all components @@ -2471,17 +2488,17 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, (op.operands[2].comps[2] < 4 && op.operands[2].comps[2] == 0xff)) shifts[3] = shifts[2] = shifts[1] = shifts[0]; - SetDst( - state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.i.x << shifts[0], srcOpers[0].value.i.y << shifts[1], - srcOpers[0].value.i.z << shifts[2], srcOpers[0].value.i.w << shifts[3])); + SetDst(state, op.operands[0], op, ShaderVariable("", srcOpers[0].value.s32v[0] << shifts[0], + srcOpers[0].value.s32v[1] << shifts[1], + srcOpers[0].value.s32v[2] << shifts[2], + srcOpers[0].value.s32v[3] << shifts[3])); break; } case OPCODE_USHR: { uint32_t shifts[] = { - srcOpers[1].value.u.x & 0x1f, srcOpers[1].value.u.y & 0x1f, srcOpers[1].value.u.z & 0x1f, - srcOpers[1].value.u.w & 0x1f, + srcOpers[1].value.u32v[0] & 0x1f, srcOpers[1].value.u32v[1] & 0x1f, + srcOpers[1].value.u32v[2] & 0x1f, srcOpers[1].value.u32v[3] & 0x1f, }; // if we were only given a single component, it's the form that shifts all components @@ -2490,17 +2507,17 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, (op.operands[2].comps[2] < 4 && op.operands[2].comps[2] == 0xff)) shifts[3] = shifts[2] = shifts[1] = shifts[0]; - SetDst( - state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.u.x >> shifts[0], srcOpers[0].value.u.y >> shifts[1], - srcOpers[0].value.u.z >> shifts[2], srcOpers[0].value.u.w >> shifts[3])); + SetDst(state, op.operands[0], op, ShaderVariable("", srcOpers[0].value.u32v[0] >> shifts[0], + srcOpers[0].value.u32v[1] >> shifts[1], + srcOpers[0].value.u32v[2] >> shifts[2], + srcOpers[0].value.u32v[3] >> shifts[3])); break; } case OPCODE_ISHR: { uint32_t shifts[] = { - srcOpers[1].value.u.x & 0x1f, srcOpers[1].value.u.y & 0x1f, srcOpers[1].value.u.z & 0x1f, - srcOpers[1].value.u.w & 0x1f, + srcOpers[1].value.u32v[0] & 0x1f, srcOpers[1].value.u32v[1] & 0x1f, + srcOpers[1].value.u32v[2] & 0x1f, srcOpers[1].value.u32v[3] & 0x1f, }; // if we were only given a single component, it's the form that shifts all components @@ -2509,37 +2526,37 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, (op.operands[2].comps[2] < 4 && op.operands[2].comps[2] == 0xff)) shifts[3] = shifts[2] = shifts[1] = shifts[0]; - SetDst( - state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.i.x >> shifts[0], srcOpers[0].value.i.y >> shifts[1], - srcOpers[0].value.i.z >> shifts[2], srcOpers[0].value.i.w >> shifts[3])); + SetDst(state, op.operands[0], op, ShaderVariable("", srcOpers[0].value.s32v[0] >> shifts[0], + srcOpers[0].value.s32v[1] >> shifts[1], + srcOpers[0].value.s32v[2] >> shifts[2], + srcOpers[0].value.s32v[3] >> shifts[3])); break; } case OPCODE_AND: SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.i.x & srcOpers[1].value.i.x, - srcOpers[0].value.i.y & srcOpers[1].value.i.y, - srcOpers[0].value.i.z & srcOpers[1].value.i.z, - srcOpers[0].value.i.w & srcOpers[1].value.i.w)); + ShaderVariable("", srcOpers[0].value.s32v[0] & srcOpers[1].value.s32v[0], + srcOpers[0].value.s32v[1] & srcOpers[1].value.s32v[1], + srcOpers[0].value.s32v[2] & srcOpers[1].value.s32v[2], + srcOpers[0].value.s32v[3] & srcOpers[1].value.s32v[3])); break; case OPCODE_OR: SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.i.x | srcOpers[1].value.i.x, - srcOpers[0].value.i.y | srcOpers[1].value.i.y, - srcOpers[0].value.i.z | srcOpers[1].value.i.z, - srcOpers[0].value.i.w | srcOpers[1].value.i.w)); + ShaderVariable("", srcOpers[0].value.s32v[0] | srcOpers[1].value.s32v[0], + srcOpers[0].value.s32v[1] | srcOpers[1].value.s32v[1], + srcOpers[0].value.s32v[2] | srcOpers[1].value.s32v[2], + srcOpers[0].value.s32v[3] | srcOpers[1].value.s32v[3])); break; case OPCODE_XOR: SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.u.x ^ srcOpers[1].value.u.x, - srcOpers[0].value.u.y ^ srcOpers[1].value.u.y, - srcOpers[0].value.u.z ^ srcOpers[1].value.u.z, - srcOpers[0].value.u.w ^ srcOpers[1].value.u.w)); + ShaderVariable("", srcOpers[0].value.u32v[0] ^ srcOpers[1].value.u32v[0], + srcOpers[0].value.u32v[1] ^ srcOpers[1].value.u32v[1], + srcOpers[0].value.u32v[2] ^ srcOpers[1].value.u32v[2], + srcOpers[0].value.u32v[3] ^ srcOpers[1].value.u32v[3])); break; case OPCODE_NOT: SetDst(state, op.operands[0], op, - ShaderVariable("", ~srcOpers[0].value.u.x, ~srcOpers[0].value.u.y, - ~srcOpers[0].value.u.z, ~srcOpers[0].value.u.w)); + ShaderVariable("", ~srcOpers[0].value.u32v[0], ~srcOpers[0].value.u32v[1], + ~srcOpers[0].value.u32v[2], ~srcOpers[0].value.u32v[3])); break; ///////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2591,51 +2608,60 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_DMOV: case OPCODE_MOV: SetDst(state, op.operands[0], op, srcOpers[0]); break; case OPCODE_DMOVC: - SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.u.x ? srcOpers[1].value.u.x : srcOpers[2].value.u.x, - srcOpers[0].value.u.x ? srcOpers[1].value.u.y : srcOpers[2].value.u.y, - srcOpers[0].value.u.y ? srcOpers[1].value.u.z : srcOpers[2].value.u.z, - srcOpers[0].value.u.y ? srcOpers[1].value.u.w : srcOpers[2].value.u.w)); + SetDst( + state, op.operands[0], op, + ShaderVariable( + "", srcOpers[0].value.u32v[0] ? srcOpers[1].value.u32v[0] : srcOpers[2].value.u32v[0], + srcOpers[0].value.u32v[0] ? srcOpers[1].value.u32v[1] : srcOpers[2].value.u32v[1], + srcOpers[0].value.u32v[1] ? srcOpers[1].value.u32v[2] : srcOpers[2].value.u32v[2], + srcOpers[0].value.u32v[1] ? srcOpers[1].value.u32v[3] : srcOpers[2].value.u32v[3])); break; case OPCODE_MOVC: - SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[0].value.i.x ? srcOpers[1].value.i.x : srcOpers[2].value.i.x, - srcOpers[0].value.i.y ? srcOpers[1].value.i.y : srcOpers[2].value.i.y, - srcOpers[0].value.i.z ? srcOpers[1].value.i.z : srcOpers[2].value.i.z, - srcOpers[0].value.i.w ? srcOpers[1].value.i.w : srcOpers[2].value.i.w)); + SetDst( + state, op.operands[0], op, + ShaderVariable( + "", srcOpers[0].value.s32v[0] ? srcOpers[1].value.s32v[0] : srcOpers[2].value.s32v[0], + srcOpers[0].value.s32v[1] ? srcOpers[1].value.s32v[1] : srcOpers[2].value.s32v[1], + srcOpers[0].value.s32v[2] ? srcOpers[1].value.s32v[2] : srcOpers[2].value.s32v[2], + srcOpers[0].value.s32v[3] ? srcOpers[1].value.s32v[3] : srcOpers[2].value.s32v[3])); break; case OPCODE_SWAPC: - SetDst(state, op.operands[0], op, - ShaderVariable("", srcOpers[1].value.i.x ? srcOpers[3].value.i.x : srcOpers[2].value.i.x, - srcOpers[1].value.i.y ? srcOpers[3].value.i.y : srcOpers[2].value.i.y, - srcOpers[1].value.i.z ? srcOpers[3].value.i.z : srcOpers[2].value.i.z, - srcOpers[1].value.i.w ? srcOpers[3].value.i.w : srcOpers[2].value.i.w)); + SetDst( + state, op.operands[0], op, + ShaderVariable( + "", srcOpers[1].value.s32v[0] ? srcOpers[3].value.s32v[0] : srcOpers[2].value.s32v[0], + srcOpers[1].value.s32v[1] ? srcOpers[3].value.s32v[1] : srcOpers[2].value.s32v[1], + srcOpers[1].value.s32v[2] ? srcOpers[3].value.s32v[2] : srcOpers[2].value.s32v[2], + srcOpers[1].value.s32v[3] ? srcOpers[3].value.s32v[3] : srcOpers[2].value.s32v[3])); - SetDst(state, op.operands[1], op, - ShaderVariable("", srcOpers[1].value.i.x ? srcOpers[2].value.i.x : srcOpers[3].value.i.x, - srcOpers[1].value.i.y ? srcOpers[2].value.i.y : srcOpers[3].value.i.y, - srcOpers[1].value.i.z ? srcOpers[2].value.i.z : srcOpers[3].value.i.z, - srcOpers[1].value.i.w ? srcOpers[2].value.i.w : srcOpers[3].value.i.w)); + SetDst( + state, op.operands[1], op, + ShaderVariable( + "", srcOpers[1].value.s32v[0] ? srcOpers[2].value.s32v[0] : srcOpers[3].value.s32v[0], + srcOpers[1].value.s32v[1] ? srcOpers[2].value.s32v[1] : srcOpers[3].value.s32v[1], + srcOpers[1].value.s32v[2] ? srcOpers[2].value.s32v[2] : srcOpers[3].value.s32v[2], + srcOpers[1].value.s32v[3] ? srcOpers[2].value.s32v[3] : srcOpers[3].value.s32v[3])); break; case OPCODE_ITOF: SetDst(state, op.operands[0], op, - ShaderVariable("", (float)srcOpers[0].value.i.x, (float)srcOpers[0].value.i.y, - (float)srcOpers[0].value.i.z, (float)srcOpers[0].value.i.w)); + ShaderVariable("", (float)srcOpers[0].value.s32v[0], (float)srcOpers[0].value.s32v[1], + (float)srcOpers[0].value.s32v[2], (float)srcOpers[0].value.s32v[3])); break; case OPCODE_UTOF: SetDst(state, op.operands[0], op, - ShaderVariable("", (float)srcOpers[0].value.u.x, (float)srcOpers[0].value.u.y, - (float)srcOpers[0].value.u.z, (float)srcOpers[0].value.u.w)); + ShaderVariable("", (float)srcOpers[0].value.u32v[0], (float)srcOpers[0].value.u32v[1], + (float)srcOpers[0].value.u32v[2], (float)srcOpers[0].value.u32v[3])); break; case OPCODE_FTOI: SetDst(state, op.operands[0], op, - ShaderVariable("", (int)srcOpers[0].value.f.x, (int)srcOpers[0].value.f.y, - (int)srcOpers[0].value.f.z, (int)srcOpers[0].value.f.w)); + ShaderVariable("", (int)srcOpers[0].value.f32v[0], (int)srcOpers[0].value.f32v[1], + (int)srcOpers[0].value.f32v[2], (int)srcOpers[0].value.f32v[3])); break; case OPCODE_FTOU: - SetDst(state, op.operands[0], op, - ShaderVariable("", (uint32_t)srcOpers[0].value.f.x, (uint32_t)srcOpers[0].value.f.y, - (uint32_t)srcOpers[0].value.f.z, (uint32_t)srcOpers[0].value.f.w)); + SetDst(state, op.operands[0], op, ShaderVariable("", (uint32_t)srcOpers[0].value.f32v[0], + (uint32_t)srcOpers[0].value.f32v[1], + (uint32_t)srcOpers[0].value.f32v[2], + (uint32_t)srcOpers[0].value.f32v[3])); break; case OPCODE_ITOD: case OPCODE_UTOD: @@ -2645,18 +2671,18 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, if(op.operation == OPCODE_ITOD) { - res[0] = (double)srcOpers[0].value.i.x; - res[1] = (double)srcOpers[0].value.i.y; + res[0] = (double)srcOpers[0].value.s32v[0]; + res[1] = (double)srcOpers[0].value.s32v[1]; } else if(op.operation == OPCODE_UTOD) { - res[0] = (double)srcOpers[0].value.u.x; - res[1] = (double)srcOpers[0].value.u.y; + res[0] = (double)srcOpers[0].value.u32v[0]; + res[1] = (double)srcOpers[0].value.u32v[1]; } else if(op.operation == OPCODE_FTOD) { - res[0] = (double)srcOpers[0].value.f.x; - res[1] = (double)srcOpers[0].value.f.y; + res[0] = (double)srcOpers[0].value.f32v[0]; + res[1] = (double)srcOpers[0].value.f32v[1]; } // if we only did a 1-wide double op, copy .xy into .zw so we can then @@ -2688,36 +2714,36 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, { if(op.operands[0].comps[1] == 0xff) // only one mask { - r.value.uv[op.operands[0].comps[0]] = uint32_t(src[0]); + r.value.u32v[op.operands[0].comps[0]] = uint32_t(src[0]); } else { - r.value.uv[op.operands[0].comps[0]] = uint32_t(src[0]); - r.value.uv[op.operands[0].comps[1]] = uint32_t(src[1]); + r.value.u32v[op.operands[0].comps[0]] = uint32_t(src[0]); + r.value.u32v[op.operands[0].comps[1]] = uint32_t(src[1]); } } else if(op.operation == OPCODE_DTOI) { if(op.operands[0].comps[1] == 0xff) // only one mask { - r.value.iv[op.operands[0].comps[0]] = int32_t(src[0]); + r.value.s32v[op.operands[0].comps[0]] = int32_t(src[0]); } else { - r.value.iv[op.operands[0].comps[0]] = int32_t(src[0]); - r.value.iv[op.operands[0].comps[1]] = int32_t(src[1]); + r.value.s32v[op.operands[0].comps[0]] = int32_t(src[0]); + r.value.s32v[op.operands[0].comps[1]] = int32_t(src[1]); } } else if(op.operation == OPCODE_DTOF) { if(op.operands[0].comps[1] == 0xff) // only one mask { - r.value.fv[op.operands[0].comps[0]] = float(src[0]); + r.value.f32v[op.operands[0].comps[0]] = float(src[0]); } else { - r.value.fv[op.operands[0].comps[0]] = float(src[0]); - r.value.fv[op.operands[0].comps[1]] = float(src[1]); + r.value.f32v[op.operands[0].comps[0]] = float(src[0]); + r.value.f32v[op.operands[0].comps[1]] = float(src[1]); } } @@ -2730,31 +2756,31 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_EQ: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.f.x == srcOpers[1].value.f.x ? ~0l : 0l), - (srcOpers[0].value.f.y == srcOpers[1].value.f.y ? ~0l : 0l), - (srcOpers[0].value.f.z == srcOpers[1].value.f.z ? ~0l : 0l), - (srcOpers[0].value.f.w == srcOpers[1].value.f.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.f32v[0] == srcOpers[1].value.f32v[0] ? ~0l : 0l), + (srcOpers[0].value.f32v[1] == srcOpers[1].value.f32v[1] ? ~0l : 0l), + (srcOpers[0].value.f32v[2] == srcOpers[1].value.f32v[2] ? ~0l : 0l), + (srcOpers[0].value.f32v[3] == srcOpers[1].value.f32v[3] ? ~0l : 0l))); break; case OPCODE_NE: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.f.x != srcOpers[1].value.f.x ? ~0l : 0l), - (srcOpers[0].value.f.y != srcOpers[1].value.f.y ? ~0l : 0l), - (srcOpers[0].value.f.z != srcOpers[1].value.f.z ? ~0l : 0l), - (srcOpers[0].value.f.w != srcOpers[1].value.f.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.f32v[0] != srcOpers[1].value.f32v[0] ? ~0l : 0l), + (srcOpers[0].value.f32v[1] != srcOpers[1].value.f32v[1] ? ~0l : 0l), + (srcOpers[0].value.f32v[2] != srcOpers[1].value.f32v[2] ? ~0l : 0l), + (srcOpers[0].value.f32v[3] != srcOpers[1].value.f32v[3] ? ~0l : 0l))); break; case OPCODE_LT: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.f.x < srcOpers[1].value.f.x ? ~0l : 0l), - (srcOpers[0].value.f.y < srcOpers[1].value.f.y ? ~0l : 0l), - (srcOpers[0].value.f.z < srcOpers[1].value.f.z ? ~0l : 0l), - (srcOpers[0].value.f.w < srcOpers[1].value.f.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.f32v[0] < srcOpers[1].value.f32v[0] ? ~0l : 0l), + (srcOpers[0].value.f32v[1] < srcOpers[1].value.f32v[1] ? ~0l : 0l), + (srcOpers[0].value.f32v[2] < srcOpers[1].value.f32v[2] ? ~0l : 0l), + (srcOpers[0].value.f32v[3] < srcOpers[1].value.f32v[3] ? ~0l : 0l))); break; case OPCODE_GE: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.f.x >= srcOpers[1].value.f.x ? ~0l : 0l), - (srcOpers[0].value.f.y >= srcOpers[1].value.f.y ? ~0l : 0l), - (srcOpers[0].value.f.z >= srcOpers[1].value.f.z ? ~0l : 0l), - (srcOpers[0].value.f.w >= srcOpers[1].value.f.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.f32v[0] >= srcOpers[1].value.f32v[0] ? ~0l : 0l), + (srcOpers[0].value.f32v[1] >= srcOpers[1].value.f32v[1] ? ~0l : 0l), + (srcOpers[0].value.f32v[2] >= srcOpers[1].value.f32v[2] ? ~0l : 0l), + (srcOpers[0].value.f32v[3] >= srcOpers[1].value.f32v[3] ? ~0l : 0l))); break; case OPCODE_DEQ: case OPCODE_DNE: @@ -2798,12 +2824,12 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, if(op.operands[0].comps[1] == 0xff) // only one mask { - r.value.uv[op.operands[0].comps[0]] = cmp1; + r.value.u32v[op.operands[0].comps[0]] = cmp1; } else { - r.value.uv[op.operands[0].comps[0]] = cmp1; - r.value.uv[op.operands[0].comps[1]] = cmp2; + r.value.u32v[op.operands[0].comps[0]] = cmp1; + r.value.u32v[op.operands[0].comps[1]] = cmp2; } SetDst(state, op.operands[0], op, r); @@ -2811,45 +2837,45 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } case OPCODE_IEQ: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.i.x == srcOpers[1].value.i.x ? ~0l : 0l), - (srcOpers[0].value.i.y == srcOpers[1].value.i.y ? ~0l : 0l), - (srcOpers[0].value.i.z == srcOpers[1].value.i.z ? ~0l : 0l), - (srcOpers[0].value.i.w == srcOpers[1].value.i.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.s32v[0] == srcOpers[1].value.s32v[0] ? ~0l : 0l), + (srcOpers[0].value.s32v[1] == srcOpers[1].value.s32v[1] ? ~0l : 0l), + (srcOpers[0].value.s32v[2] == srcOpers[1].value.s32v[2] ? ~0l : 0l), + (srcOpers[0].value.s32v[3] == srcOpers[1].value.s32v[3] ? ~0l : 0l))); break; case OPCODE_INE: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.i.x != srcOpers[1].value.i.x ? ~0l : 0l), - (srcOpers[0].value.i.y != srcOpers[1].value.i.y ? ~0l : 0l), - (srcOpers[0].value.i.z != srcOpers[1].value.i.z ? ~0l : 0l), - (srcOpers[0].value.i.w != srcOpers[1].value.i.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.s32v[0] != srcOpers[1].value.s32v[0] ? ~0l : 0l), + (srcOpers[0].value.s32v[1] != srcOpers[1].value.s32v[1] ? ~0l : 0l), + (srcOpers[0].value.s32v[2] != srcOpers[1].value.s32v[2] ? ~0l : 0l), + (srcOpers[0].value.s32v[3] != srcOpers[1].value.s32v[3] ? ~0l : 0l))); break; case OPCODE_IGE: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.i.x >= srcOpers[1].value.i.x ? ~0l : 0l), - (srcOpers[0].value.i.y >= srcOpers[1].value.i.y ? ~0l : 0l), - (srcOpers[0].value.i.z >= srcOpers[1].value.i.z ? ~0l : 0l), - (srcOpers[0].value.i.w >= srcOpers[1].value.i.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.s32v[0] >= srcOpers[1].value.s32v[0] ? ~0l : 0l), + (srcOpers[0].value.s32v[1] >= srcOpers[1].value.s32v[1] ? ~0l : 0l), + (srcOpers[0].value.s32v[2] >= srcOpers[1].value.s32v[2] ? ~0l : 0l), + (srcOpers[0].value.s32v[3] >= srcOpers[1].value.s32v[3] ? ~0l : 0l))); break; case OPCODE_ILT: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.i.x < srcOpers[1].value.i.x ? ~0l : 0l), - (srcOpers[0].value.i.y < srcOpers[1].value.i.y ? ~0l : 0l), - (srcOpers[0].value.i.z < srcOpers[1].value.i.z ? ~0l : 0l), - (srcOpers[0].value.i.w < srcOpers[1].value.i.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.s32v[0] < srcOpers[1].value.s32v[0] ? ~0l : 0l), + (srcOpers[0].value.s32v[1] < srcOpers[1].value.s32v[1] ? ~0l : 0l), + (srcOpers[0].value.s32v[2] < srcOpers[1].value.s32v[2] ? ~0l : 0l), + (srcOpers[0].value.s32v[3] < srcOpers[1].value.s32v[3] ? ~0l : 0l))); break; case OPCODE_ULT: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.u.x < srcOpers[1].value.u.x ? ~0l : 0l), - (srcOpers[0].value.u.y < srcOpers[1].value.u.y ? ~0l : 0l), - (srcOpers[0].value.u.z < srcOpers[1].value.u.z ? ~0l : 0l), - (srcOpers[0].value.u.w < srcOpers[1].value.u.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.u32v[0] < srcOpers[1].value.u32v[0] ? ~0l : 0l), + (srcOpers[0].value.u32v[1] < srcOpers[1].value.u32v[1] ? ~0l : 0l), + (srcOpers[0].value.u32v[2] < srcOpers[1].value.u32v[2] ? ~0l : 0l), + (srcOpers[0].value.u32v[3] < srcOpers[1].value.u32v[3] ? ~0l : 0l))); break; case OPCODE_UGE: SetDst(state, op.operands[0], op, - ShaderVariable("", (srcOpers[0].value.u.x >= srcOpers[1].value.u.x ? ~0l : 0l), - (srcOpers[0].value.u.y >= srcOpers[1].value.u.y ? ~0l : 0l), - (srcOpers[0].value.u.z >= srcOpers[1].value.u.z ? ~0l : 0l), - (srcOpers[0].value.u.w >= srcOpers[1].value.u.w ? ~0l : 0l))); + ShaderVariable("", (srcOpers[0].value.u32v[0] >= srcOpers[1].value.u32v[0] ? ~0l : 0l), + (srcOpers[0].value.u32v[1] >= srcOpers[1].value.u32v[1] ? ~0l : 0l), + (srcOpers[0].value.u32v[2] >= srcOpers[1].value.u32v[2] ? ~0l : 0l), + (srcOpers[0].value.u32v[3] >= srcOpers[1].value.u32v[3] ? ~0l : 0l))); break; ///////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2857,8 +2883,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_IMM_ATOMIC_ALLOC: { - BindingSlot slot = - GetBindingSlotForIdentifier(*program, TYPE_UNORDERED_ACCESS_VIEW, srcOpers[0].value.u.x); + BindingSlot slot = GetBindingSlotForIdentifier(*program, TYPE_UNORDERED_ACCESS_VIEW, + srcOpers[0].value.u32v[0]); GlobalState::UAVIterator uav = global.uavs.find(slot); if(uav == global.uavs.end()) { @@ -2879,8 +2905,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_IMM_ATOMIC_CONSUME: { - BindingSlot slot = - GetBindingSlotForIdentifier(*program, TYPE_UNORDERED_ACCESS_VIEW, srcOpers[0].value.u.x); + BindingSlot slot = GetBindingSlotForIdentifier(*program, TYPE_UNORDERED_ACCESS_VIEW, + srcOpers[0].value.u32v[0]); GlobalState::UAVIterator uav = global.uavs.find(slot); if(uav == global.uavs.end()) { @@ -3057,15 +3083,15 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, if(data) { - data += (offset + dstAddress->value.u.x) * stride; + data += (offset + dstAddress->value.u32v[0]) * stride; if(structured) - data += dstAddress->value.u.y; + data += dstAddress->value.u32v[1]; } // if out of bounds, undefined result is returned to dst0 for immediate operands, // so we only need to care about the in-bounds case. // Also helper/inactive pixels are not allowed to modify UAVs - if(data && offset + dstAddress->value.u.x < numElems && !Finished()) + if(data && offset + dstAddress->value.u32v[0] < numElems && !Finished()) { uint32_t *udst = (uint32_t *)data; int32_t *idst = (int32_t *)data; @@ -3076,10 +3102,10 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } // not verified below since by definition the operations that expect usrc1 will have it - uint32_t *usrc0 = src0->value.uv; - uint32_t *usrc1 = src1->value.uv; + uint32_t *usrc0 = src0->value.u32v.data(); + uint32_t *usrc1 = src1->value.u32v.data(); - int32_t *isrc0 = src0->value.iv; + int32_t *isrc0 = src0->value.s32v.data(); switch(op.operation) { @@ -3180,8 +3206,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } } - elemOffset = srcOpers[1].value.u.x; - elemIdx = srcOpers[0].value.u.x; + elemOffset = srcOpers[1].value.u32v[0]; + elemIdx = srcOpers[0].value.u32v[0]; } else if(op.operation == OPCODE_LD_UAV_TYPED || op.operation == OPCODE_STORE_UAV_TYPED) { @@ -3197,12 +3223,12 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, gsm = (op.operands[0].type == TYPE_THREAD_GROUP_SHARED_MEMORY); } - elemIdx = srcOpers[0].value.u.x; + elemIdx = srcOpers[0].value.u32v[0]; // could be a tex load - texCoords[0] = srcOpers[0].value.u.x; - texCoords[1] = srcOpers[0].value.u.y; - texCoords[2] = srcOpers[0].value.u.z; + texCoords[0] = srcOpers[0].value.u32v[0]; + texCoords[1] = srcOpers[0].value.u32v[1]; + texCoords[2] = srcOpers[0].value.u32v[2]; stride = 4; srv = false; @@ -3224,7 +3250,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } // the index is supposed to be a multiple of 4 but the behaviour seems to be to round down - elemIdx = (srcOpers[0].value.u.x & ~0x3); + elemIdx = (srcOpers[0].value.u32v[0] & ~0x3); stride = 1; } @@ -3392,7 +3418,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, if(comp == 0xff) comp = 0; - fetch.value.uv[c] = result.value.uv[comp]; + fetch.value.u32v[c] = result.value.u32v[comp]; } if(op.operation != OPCODE_LD_RAW && op.operation != OPCODE_LD_STRUCTURED) @@ -3402,7 +3428,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // to match this expectation, propogate the component across. if(op.operands[0].comps[0] != 0xff && op.operands[0].comps[1] == 0xff && op.operands[0].comps[2] == 0xff && op.operands[0].comps[3] == 0xff) - fetch.value.uv[0] = fetch.value.uv[op.operands[0].comps[0]]; + fetch.value.u32v[0] = fetch.value.u32v[op.operands[0].comps[0]]; } SetDst(state, op.operands[0], op, fetch); @@ -3452,12 +3478,12 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, if(op.operation == OPCODE_EVAL_SAMPLE_INDEX) { - key.sample = srcOpers[1].value.i.x; + key.sample = srcOpers[1].value.s32v[0]; } else if(op.operation == OPCODE_EVAL_SNAPPED) { - key.offsetx = RDCCLAMP(srcOpers[1].value.i.x, -8, 7); - key.offsety = RDCCLAMP(srcOpers[1].value.i.y, -8, 7); + key.offsetx = RDCCLAMP(srcOpers[1].value.s32v[0], -8, 7); + key.offsety = RDCCLAMP(srcOpers[1].value.s32v[1], -8, 7); } else if(op.operation == OPCODE_EVAL_CENTROID) { @@ -3473,7 +3499,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(int i = 0; i < 4; i++) if(op.operands[1].comps[i] < 4) - var.value.uv[i] = it->second.value.uv[op.operands[1].comps[i]]; + var.value.u32v[i] = it->second.value.u32v[op.operands[1].comps[i]]; SetDst(state, op.operands[0], op, var); } @@ -3520,24 +3546,24 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // "If there is no resource bound to the specified slot, 0 is returned." // lookup sample pos if we got a count from above - if(op.operation == OPCODE_SAMPLE_POS && result.value.u.x > 0 && + if(op.operation == OPCODE_SAMPLE_POS && result.value.u32v[0] > 0 && (op.operands[2].type == TYPE_IMMEDIATE32 || op.operands[2].type == TYPE_TEMP)) { // assume standard sample pattern - this might not hold in all cases // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476218(v=vs.85).aspx - uint32_t sampleIndex = srcOpers[1].value.u.x; - uint32_t sampleCount = result.value.u.x; + uint32_t sampleIndex = srcOpers[1].value.u32v[0]; + uint32_t sampleCount = result.value.u32v[0]; if(sampleIndex >= sampleCount) { // Per HLSL docs, if sampleIndex is out of bounds a zero vector is returned RDCWARN("sample index %u is out of bounds on resource bound to sample_pos (%u samples)", sampleIndex, sampleCount); - result.value.f.x = 0.0f; - result.value.f.y = 0.0f; - result.value.f.z = 0.0f; - result.value.f.w = 0.0f; + result.value.f32v[0] = 0.0f; + result.value.f32v[1] = 0.0f; + result.value.f32v[2] = 0.0f; + result.value.f32v[3] = 0.0f; } else { @@ -3600,20 +3626,20 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } else // unsupported sample count { - RDCERR("Unsupported sample count on resource for sample_pos: %u", result.value.u.x); + RDCERR("Unsupported sample count on resource for sample_pos: %u", result.value.u32v[0]); sample_pattern = NULL; } if(sample_pattern == NULL) { - result.value.f.x = 0.0f; - result.value.f.y = 0.0f; + result.value.f32v[0] = 0.0f; + result.value.f32v[1] = 0.0f; } else { - result.value.f.x = sample_pattern[sampleIndex * 2 + 0]; - result.value.f.y = sample_pattern[sampleIndex * 2 + 1]; + result.value.f32v[0] = sample_pattern[sampleIndex * 2 + 0]; + result.value.f32v[1] = sample_pattern[sampleIndex * 2 + 1]; } } @@ -3626,9 +3652,9 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(int i = 0; i < 4; i++) { if(op.operands[1].comps[i] == 0xff) - swizzled.value.uv[i] = result.value.uv[0]; + swizzled.value.u32v[i] = result.value.u32v[0]; else - swizzled.value.uv[i] = result.value.uv[op.operands[1].comps[i]]; + swizzled.value.u32v[i] = result.value.u32v[op.operands[1].comps[i]]; } // apply ret type @@ -3639,10 +3665,10 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } else if(op.resinfoRetType == RETTYPE_FLOAT) { - result.value.f.x = (float)swizzled.value.u.x; - result.value.f.y = (float)swizzled.value.u.y; - result.value.f.z = (float)swizzled.value.u.z; - result.value.f.w = (float)swizzled.value.u.w; + result.value.f32v[0] = (float)swizzled.value.u32v[0]; + result.value.f32v[1] = (float)swizzled.value.u32v[1]; + result.value.f32v[2] = (float)swizzled.value.u32v[2]; + result.value.f32v[3] = (float)swizzled.value.u32v[3]; result.type = VarType::Float; } else @@ -3656,7 +3682,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // to match this expectation, propogate the component across. if(op.operands[0].comps[0] != 0xff && op.operands[0].comps[1] == 0xff && op.operands[0].comps[2] == 0xff && op.operands[0].comps[3] == 0xff) - result.value.uv[0] = result.value.uv[op.operands[0].comps[0]]; + result.value.u32v[0] = result.value.u32v[op.operands[0].comps[0]]; SetDst(state, op.operands[0], op, result); @@ -3681,9 +3707,9 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(int i = 0; i < 4; i++) { if(op.operands[1].comps[i] == 0xff) - swizzled.value.uv[i] = result.value.uv[0]; + swizzled.value.u32v[i] = result.value.u32v[0]; else - swizzled.value.uv[i] = result.value.uv[op.operands[1].comps[i]]; + swizzled.value.u32v[i] = result.value.u32v[op.operands[1].comps[i]]; } result = swizzled; @@ -3694,7 +3720,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // to match this expectation, propogate the component across. if(op.operands[0].comps[0] != 0xff && op.operands[0].comps[1] == 0xff && op.operands[0].comps[2] == 0xff && op.operands[0].comps[3] == 0xff) - result.value.uv[0] = result.value.uv[op.operands[0].comps[0]]; + result.value.u32v[0] = result.value.u32v[op.operands[0].comps[0]]; SetDst(state, op.operands[0], op, result); } @@ -3710,7 +3736,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_RESINFO: { // spec says "srcMipLevel is read as an unsigned integer scalar" - uint32_t mipLevel = srcOpers[0].value.u.x; + uint32_t mipLevel = srcOpers[0].value.u32v[0]; size_t numIndices = program->IsShaderModel51() ? 2 : 1; if(op.operands[2].indices.size() == numIndices && op.operands[2].indices[0].absolute && @@ -3758,18 +3784,18 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, for(int i = 0; i < 4; i++) { if(op.operands[2].comps[i] == 0xff) - swizzled.value.uv[i] = result.value.uv[0]; + swizzled.value.u32v[i] = result.value.u32v[0]; else - swizzled.value.uv[i] = result.value.uv[op.operands[2].comps[i]]; + swizzled.value.u32v[i] = result.value.u32v[op.operands[2].comps[i]]; } // apply ret type if(op.resinfoRetType == RETTYPE_FLOAT) { - result.value.f.x = (float)swizzled.value.u.x; - result.value.f.y = (float)swizzled.value.u.y; - result.value.f.z = (float)swizzled.value.u.z; - result.value.f.w = (float)swizzled.value.u.w; + result.value.f32v[0] = (float)swizzled.value.u32v[0]; + result.value.f32v[1] = (float)swizzled.value.u32v[1]; + result.value.f32v[2] = (float)swizzled.value.u32v[2]; + result.value.f32v[3] = (float)swizzled.value.u32v[3]; result.type = VarType::Float; } else if(op.resinfoRetType == RETTYPE_RCPFLOAT) @@ -3777,21 +3803,21 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // only width/height/depth values we set are reciprocated, other values // are just left as is if(dim <= 1) - result.value.f.x = 1.0f / (float)swizzled.value.u.x; + result.value.f32v[0] = 1.0f / (float)swizzled.value.u32v[0]; else - result.value.f.x = (float)swizzled.value.u.x; + result.value.f32v[0] = (float)swizzled.value.u32v[0]; if(dim <= 2) - result.value.f.y = 1.0f / (float)swizzled.value.u.y; + result.value.f32v[1] = 1.0f / (float)swizzled.value.u32v[1]; else - result.value.f.y = (float)swizzled.value.u.y; + result.value.f32v[1] = (float)swizzled.value.u32v[1]; if(dim <= 3) - result.value.f.z = 1.0f / (float)swizzled.value.u.z; + result.value.f32v[2] = 1.0f / (float)swizzled.value.u32v[2]; else - result.value.f.z = (float)swizzled.value.u.z; + result.value.f32v[2] = (float)swizzled.value.u32v[2]; - result.value.f.w = (float)swizzled.value.u.w; + result.value.f32v[3] = (float)swizzled.value.u32v[3]; result.type = VarType::Float; } else if(op.resinfoRetType == RETTYPE_UINT) @@ -3805,7 +3831,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // to match this expectation, propogate the component across. if(op.operands[0].comps[0] != 0xff && op.operands[0].comps[1] == 0xff && op.operands[0].comps[2] == 0xff && op.operands[0].comps[3] == 0xff) - result.value.uv[0] = result.value.uv[op.operands[0].comps[0]]; + result.value.u32v[0] = result.value.u32v[op.operands[0].comps[0]]; SetDst(state, op.operands[0], op, result); } @@ -3884,8 +3910,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, { result = ShaderVariable("", 0.0f, 0.0f, 0.0f, 0.0f); - if(srcOpers[0].value.uv[0] < numElems) - result = TypedUAVLoad(fmt, data + srcOpers[0].value.uv[0] * fmt.Stride()); + if(srcOpers[0].value.u32v[0] < numElems) + result = TypedUAVLoad(fmt, data + srcOpers[0].value.u32v[0] * fmt.Stride()); } ShaderVariable fetch("", 0U, 0U, 0U, 0U); @@ -3896,7 +3922,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, if(op.operands[2].comps[c] == 0xff) comp = 0; - fetch.value.uv[c] = result.value.uv[comp]; + fetch.value.u32v[c] = result.value.u32v[comp]; } // if we are assigning into a scalar, SetDst expects the result to be in .x (as normally @@ -3904,7 +3930,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // to match this expectation, propogate the component across. if(op.operands[0].comps[0] != 0xff && op.operands[0].comps[1] == 0xff && op.operands[0].comps[2] == 0xff && op.operands[0].comps[3] == 0xff) - fetch.value.uv[0] = fetch.value.uv[op.operands[0].comps[0]]; + fetch.value.u32v[0] = fetch.value.u32v[op.operands[0].comps[0]]; SetDst(state, op.operands[0], op, fetch); @@ -3922,7 +3948,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // With SM5.1, resource arrays need to offset the shader register by the array index if(program->IsShaderModel51()) - resourceBinding.shaderRegister = srcOpers[1].value.u.y; + resourceBinding.shaderRegister = srcOpers[1].value.u32v[1]; // doesn't seem like these are ever less than four components, even if the texture is // declared for example. @@ -3978,12 +4004,12 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, int multisampleIndex = 0; if(srcOpers.size() >= 3) - multisampleIndex = srcOpers[2].value.i.x; + multisampleIndex = srcOpers[2].value.s32v[0]; float lodOrCompareValue = 0.0f; if(srcOpers.size() >= 4) - lodOrCompareValue = srcOpers[3].value.f.x; + lodOrCompareValue = srcOpers[3].value.f32v[0]; if(op.operation == OPCODE_GATHER4_PO_C) - lodOrCompareValue = srcOpers[4].value.f.x; + lodOrCompareValue = srcOpers[4].value.f32v[0]; uint8_t swizzle[4] = {0}; for(int i = 0; i < 4; i++) @@ -4004,7 +4030,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // for bias instruction we can't do a SampleGradBias, so add the bias into the sampler state. float samplerBias = 0.0f; if(op.operation == OPCODE_SAMPLE_B) - samplerBias = srcOpers[3].value.f.x; + samplerBias = srcOpers[3].value.f32v[0]; SampleGatherResourceData resourceData; resourceData.dim = resourceDim; @@ -4027,7 +4053,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, { // should be a better way of doing this if(op.operands[0].comps[1] == 0xff) - lookupResult.value.iv[0] = lookupResult.value.iv[op.operands[0].comps[0]]; + lookupResult.value.s32v[0] = lookupResult.value.s32v[op.operands[0].comps[0]]; SetDst(state, op.operands[0], op, lookupResult); } @@ -4043,7 +4069,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_SWITCH: { - uint32_t switchValue = GetSrc(op.operands[0], op).value.u.x; + uint32_t switchValue = GetSrc(op.operands[0], op).value.u32v[0]; int depth = 0; @@ -4078,7 +4104,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, if(nextOp.operation == OPCODE_CASE) { - uint32_t caseValue = GetSrc(nextOp.operands[0], nextOp).value.u.x; + uint32_t caseValue = GetSrc(nextOp.operands[0], nextOp).value.u32v[0]; // comparison is defined to be bitwise if(caseValue == switchValue) @@ -4129,7 +4155,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, { int depth = 0; - int32_t test = op.operation == OPCODE_CONTINUEC ? GetSrc(op.operands[0], op).value.i.x : 0; + int32_t test = op.operation == OPCODE_CONTINUEC ? GetSrc(op.operands[0], op).value.s32v[0] : 0; if(op.operation == OPCODE_CONTINUE || op.operation == OPCODE_CONTINUEC) depth = 1; @@ -4161,7 +4187,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_BREAK: case OPCODE_BREAKC: { - int32_t test = op.operation == OPCODE_BREAKC ? GetSrc(op.operands[0], op).value.i.x : 0; + int32_t test = op.operation == OPCODE_BREAKC ? GetSrc(op.operands[0], op).value.s32v[0] : 0; if((test == 0 && !op.nonzero) || (test != 0 && op.nonzero) || op.operation == OPCODE_BREAK) { @@ -4194,7 +4220,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } case OPCODE_IF: { - int32_t test = GetSrc(op.operands[0], op).value.i.x; + int32_t test = GetSrc(op.operands[0], op).value.s32v[0]; if((test == 0 && !op.nonzero) || (test != 0 && op.nonzero)) { @@ -4262,7 +4288,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, } case OPCODE_DISCARD: { - int32_t test = GetSrc(op.operands[0], op).value.i.x; + int32_t test = GetSrc(op.operands[0], op).value.s32v[0]; if((test != 0 && !op.nonzero) || (test == 0 && op.nonzero)) { @@ -4277,7 +4303,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, case OPCODE_RET: case OPCODE_RETC: { - int32_t test = op.operation == OPCODE_RETC ? GetSrc(op.operands[0], op).value.i.x : 0; + int32_t test = op.operation == OPCODE_RETC ? GetSrc(op.operands[0], op).value.s32v[0] : 0; if((test == 0 && !op.nonzero) || (test != 0 && op.nonzero) || op.operation == OPCODE_RET) { @@ -4308,8 +4334,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, else if(op.texelOffset[0] == 2) { dstAddress = srcOpers[param++]; - dstAddress.value.u.y = srcOpers[param++].value.u.x; - dstAddress.value.u.z = srcOpers[param++].value.u.z; + dstAddress.value.u32v[1] = srcOpers[param++].value.u32v[0]; + dstAddress.value.u32v[2] = srcOpers[param++].value.u32v[2]; } else { @@ -4326,8 +4352,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, else if(op.texelOffset[1] == 2) { compare = srcOpers[param++]; - compare.value.u.y = srcOpers[param++].value.u.x; - compare.value.u.z = srcOpers[param++].value.u.z; + compare.value.u32v[1] = srcOpers[param++].value.u32v[0]; + compare.value.u32v[2] = srcOpers[param++].value.u32v[2]; } else { @@ -4343,8 +4369,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, else if(op.texelOffset[2] == 2) { value = srcOpers[param++]; - value.value.u.y = srcOpers[param++].value.u.x; - value.value.u.z = srcOpers[param++].value.u.z; + value.value.u32v[1] = srcOpers[param++].value.u32v[0]; + value.value.u32v[2] = srcOpers[param++].value.u32v[2]; } else { @@ -4375,13 +4401,13 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, { if(uav->second.tex) { - data += dstAddress.value.u.x * stride; - data += dstAddress.value.u.y * uav->second.rowPitch; - data += dstAddress.value.u.z * uav->second.depthPitch; + data += dstAddress.value.u32v[0] * stride; + data += dstAddress.value.u32v[1] * uav->second.rowPitch; + data += dstAddress.value.u32v[2] * uav->second.depthPitch; } else { - data += uav->second.firstElement * stride + dstAddress.value.u.x; + data += uav->second.firstElement * stride + dstAddress.value.u32v[0]; } } @@ -4391,9 +4417,9 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, uint64_t *data64 = (uint64_t *)data; - result.value.u.x = uint32_t(*data64); + result.value.u32v[0] = uint32_t(*data64); SetDst(state, op.operands[0], op, result); - result.value.u.x = uint32_t((*data64) >> 32U); + result.value.u32v[0] = uint32_t((*data64) >> 32U); SetDst(state, op.operands[1], op, result); uint64_t compare64 = compare.value.u64v[0]; @@ -4600,9 +4626,9 @@ void ApplyDerivatives(GlobalState &global, rdcarray &quad, int reg, { for(int w = 0; w < numWords; w++) { - quad[quadIdxA].inputs[reg].value.fv[element + w] += signmul * data[w]; + quad[quadIdxA].inputs[reg].value.f32v[element + w] += signmul * data[w]; if(quadIdxB >= 0) - quad[quadIdxB].inputs[reg].value.fv[element + w] += signmul * data[w]; + quad[quadIdxB].inputs[reg].value.f32v[element + w] += signmul * data[w]; } // quick check to see if this register was evaluated @@ -4615,7 +4641,7 @@ void ApplyDerivatives(GlobalState &global, rdcarray &quad, int reg, reg == it->first.inputRegisterIndex) { for(int w = 0; w < numWords; w++) - it->second.value.fv[element + w] += data[w]; + it->second.value.f32v[element + w] += data[w]; } } } @@ -5719,24 +5745,24 @@ TEST_CASE("DXBC debugging helpers", "[program]") ShaderVariable v2 = sat(v, VarType::Float); - CHECK(v2.value.f.x == 1.0f); - CHECK(v2.value.f.y == 0.0f); - CHECK(v2.value.f.z == 0.0f); - CHECK(v2.value.f.w == 1.0f); + CHECK(v2.value.f32v[0] == 1.0f); + CHECK(v2.value.f32v[1] == 0.0f); + CHECK(v2.value.f32v[2] == 0.0f); + CHECK(v2.value.f32v[3] == 1.0f); v2 = neg(v, VarType::Float); - CHECK(v2.value.f.x == -b); - CHECK(RDCISNAN(v2.value.f.y)); - CHECK(v2.value.f.z == posinf); - CHECK(v2.value.f.w == neginf); + CHECK(v2.value.f32v[0] == -b); + CHECK(RDCISNAN(v2.value.f32v[1])); + CHECK(v2.value.f32v[2] == posinf); + CHECK(v2.value.f32v[3] == neginf); v2 = abs(v, VarType::Float); - CHECK(v2.value.f.x == b); - CHECK(RDCISNAN(v2.value.f.y)); - CHECK(v2.value.f.z == posinf); - CHECK(v2.value.f.w == posinf); + CHECK(v2.value.f32v[0] == b); + CHECK(RDCISNAN(v2.value.f32v[1])); + CHECK(v2.value.f32v[2] == posinf); + CHECK(v2.value.f32v[3] == posinf); }; SECTION("test denorm flushing") diff --git a/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp b/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp index fd3d276bd..35c3727d0 100644 --- a/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp @@ -278,11 +278,11 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType, Constant v; v.type = curType; if(curType->bitWidth == 16) - v.val.fv[0] = ConvertFromHalf(uint16_t(constant.ops[0] & 0xffff)); + v.val.f32v[0] = ConvertFromHalf(uint16_t(constant.ops[0] & 0xffff)); else if(curType->bitWidth == 32) - memcpy(&v.val.fv[0], &constant.ops[0], sizeof(float)); + memcpy(&v.val.f32v[0], &constant.ops[0], sizeof(float)); else - memcpy(&v.val.dv[0], &constant.ops[0], sizeof(double)); + memcpy(&v.val.f64v[0], &constant.ops[0], sizeof(double)); addConstant(v); } else if(IS_KNOWN(constant.id, ConstantsRecord::STRING) || @@ -333,7 +333,7 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType, } else if(v.type->type == Type::Struct) { - v.type = v.type->members[v.members[idx].val.uv[0]]; + v.type = v.type->members[v.members[idx].val.u32v[0]]; } else { @@ -360,7 +360,7 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType, if(member) { if(v.type->bitWidth <= 32) - v.val.uv[m] = member->val.uv[m]; + v.val.u32v[m] = member->val.u32v[m]; else v.val.u64v[m] = member->val.u64v[m]; } @@ -401,7 +401,7 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType, for(size_t m = 0; m < constant.ops.size(); m++) { if(v.type->bitWidth <= 32) - v.val.uv[m] = constant.ops[m] & ((1ULL << v.type->bitWidth) - 1); + v.val.u32v[m] = constant.ops[m] & ((1ULL << v.type->bitWidth) - 1); else v.val.u64v[m] = constant.ops[m]; } @@ -413,7 +413,7 @@ void ParseConstant(const LLVMBC::BlockOrRecord &constant, const Type *&curType, Constant el; el.type = v.type->inner; if(el.type->bitWidth <= 32) - el.val.uv[0] = constant.ops[m] & ((1ULL << el.type->bitWidth) - 1); + el.val.u32v[0] = constant.ops[m] & ((1ULL << el.type->bitWidth) - 1); else el.val.u64v[m] = constant.ops[m]; v.members.push_back(el); @@ -1639,7 +1639,7 @@ Program::Program(const byte *bytes, size_t length) Symbol s = inst.args[idx]; // if it's a struct the index must be constant RDCASSERT(s.type == SymbolType::Constant); - inst.type = inst.type->members[GetFunctionConstant(f, s.idx)->val.uv[0]]; + inst.type = inst.type->members[GetFunctionConstant(f, s.idx)->val.u32v[0]]; } else { diff --git a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp index 73abc7043..d2dabbdbb 100644 --- a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp @@ -1211,7 +1211,7 @@ void Program::MakeDisassemblyString() { if(inst.args[0].type == SymbolType::Constant) { - uint32_t opcode = GetFunctionConstant(func, inst.args[0].idx)->val.uv[0]; + uint32_t opcode = GetFunctionConstant(func, inst.args[0].idx)->val.u32v[0]; if(opcode < ARRAY_COUNT(funcSigs)) { m_Disassembly += " ; "; @@ -1225,9 +1225,9 @@ void Program::MakeDisassemblyString() if(inst.args[2].type == SymbolType::Constant && inst.args[3].type == SymbolType::Constant) { ResourceClass resClass = - (ResourceClass)GetFunctionConstant(func, inst.args[2].idx)->val.uv[0]; + (ResourceClass)GetFunctionConstant(func, inst.args[2].idx)->val.u32v[0]; ResourceKind resKind = - (ResourceKind)GetFunctionConstant(func, inst.args[3].idx)->val.uv[0]; + (ResourceKind)GetFunctionConstant(func, inst.args[3].idx)->val.u32v[0]; m_Disassembly += " resource: "; @@ -1239,8 +1239,8 @@ void Program::MakeDisassemblyString() if(props && !props->nullconst) { - packedProps[0] = props->members[0].val.uv[0]; - packedProps[1] = props->members[1].val.uv[0]; + packedProps[0] = props->members[0].val.u32v[0]; + packedProps[1] = props->members[1].val.u32v[0]; } ComponentType compType = ComponentType(packedProps[0] & 0x1f); @@ -1721,9 +1721,9 @@ rdcstr Constant::toString(bool withType) const { double orig; if(type->bitWidth > 32) - orig = val.dv[0]; + orig = val.f64v[0]; else - orig = val.fv[0]; + orig = val.f32v[0]; // NaNs/infs are printed as hex to ensure we don't lose bits if(RDCISFINITE(orig)) @@ -1745,9 +1745,9 @@ rdcstr Constant::toString(bool withType) const if(type->bitWidth > 32) ret += StringFormat::Fmt("%lld", val.s64v[0]); else if(type->bitWidth == 1) - ret += val.uv[0] ? "true" : "false"; + ret += val.u32v[0] ? "true" : "false"; else - ret += StringFormat::Fmt("%d", val.iv[0]); + ret += StringFormat::Fmt("%d", val.s32v[0]); } } else if(type->type == Type::Vector) @@ -1759,9 +1759,9 @@ rdcstr Constant::toString(bool withType) const { // TODO need to know how to determine signedness here if(type->bitWidth > 32) - ret += StringFormat::Fmt("%le", val.dv[i]); + ret += StringFormat::Fmt("%le", val.f64v[i]); else - ret += StringFormat::Fmt("%e", val.fv[i]); + ret += StringFormat::Fmt("%e", val.f32v[i]); } else if(type->scalarType == Type::Int) { @@ -1769,7 +1769,7 @@ rdcstr Constant::toString(bool withType) const if(type->bitWidth > 32) ret += StringFormat::Fmt("%llu", val.u64v[i]); else - ret += StringFormat::Fmt("%u", val.uv[i]); + ret += StringFormat::Fmt("%u", val.u32v[i]); } } ret += ">"; diff --git a/renderdoc/driver/shaders/dxil/dxil_reflect.cpp b/renderdoc/driver/shaders/dxil/dxil_reflect.cpp index 3c51d4133..72b4b9a31 100644 --- a/renderdoc/driver/shaders/dxil/dxil_reflect.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_reflect.cpp @@ -88,7 +88,7 @@ enum class StructMemberAnnotation template T getival(const Metadata *m) { - return T(m->constant->val.uv[0]); + return T(m->constant->val.u32v[0]); } void Program::FetchComputeProperties(DXBC::Reflection *reflection) diff --git a/renderdoc/driver/shaders/spirv/spirv_debug_glsl450.cpp b/renderdoc/driver/shaders/spirv/spirv_debug_glsl450.cpp index 05c06f1d0..d3440179c 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug_glsl450.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug_glsl450.cpp @@ -299,7 +299,7 @@ ShaderVariable Determinant(ThreadState &state, uint32_t, const rdcarray &par } for(uint8_t c = 0; c < m.rows * m.columns; c++) - m.value.fv[c] = floatComp(var, c); + m.value.f32v[c] = floatComp(var, c); } RDCASSERTEQUAL(m.rows, m.columns); @@ -307,26 +307,26 @@ ShaderVariable Determinant(ThreadState &state, uint32_t, const rdcarray &par if(m.rows == 4) { Matrix4f mat; - mat.SetFrom(m.value.fv); - m.value.fv[0] = mat.Determinant(); + mat.SetFrom(m.value.f32v.data()); + m.value.f32v[0] = mat.Determinant(); } else if(m.rows == 3) { Matrix3f mat; - mat.SetFrom(m.value.fv); - m.value.fv[0] = mat.Determinant(); + mat.SetFrom(m.value.f32v.data()); + m.value.f32v[0] = mat.Determinant(); } else if(m.rows == 2) { Matrix2f mat; - mat.SetFrom(m.value.fv); - m.value.fv[0] = mat.Determinant(); + mat.SetFrom(m.value.f32v.data()); + m.value.f32v[0] = mat.Determinant(); } m.rows = m.columns = 1; if(var.type != VarType::Float) { - float f = m.value.fv[0]; + float f = m.value.f32v[0]; setFloatComp(m, 0, f); } @@ -350,7 +350,7 @@ ShaderVariable MatrixInverse(ThreadState &state, uint32_t, const rdcarray &p } for(uint8_t c = 0; c < m.rows * m.columns; c++) - m.value.fv[c] = floatComp(var, c); + m.value.f32v[c] = floatComp(var, c); } RDCASSERTEQUAL(m.rows, m.columns); @@ -358,27 +358,27 @@ ShaderVariable MatrixInverse(ThreadState &state, uint32_t, const rdcarray &p if(m.rows == 4) { Matrix4f mat; - mat.SetFrom(m.value.fv); - memcpy(m.value.fv, mat.Inverse().Data(), sizeof(mat)); + mat.SetFrom(m.value.f32v.data()); + memcpy(m.value.f32v.data(), mat.Inverse().Data(), sizeof(mat)); } else if(m.rows == 3) { Matrix3f mat; - mat.SetFrom(m.value.fv); - memcpy(m.value.fv, mat.Inverse().Data(), sizeof(mat)); + mat.SetFrom(m.value.f32v.data()); + memcpy(m.value.f32v.data(), mat.Inverse().Data(), sizeof(mat)); } else if(m.rows == 2) { Matrix2f mat; - mat.SetFrom(m.value.fv); - memcpy(m.value.fv, mat.Inverse().Data(), sizeof(mat)); + mat.SetFrom(m.value.f32v.data()); + memcpy(m.value.f32v.data(), mat.Inverse().Data(), sizeof(mat)); } if(var.type != VarType::Float) { var = m; for(uint8_t c = 0; c < m.rows * m.columns; c++) - setFloatComp(m, c, var.value.fv[c]); + setFloatComp(m, c, var.value.f32v[c]); } return m; @@ -834,12 +834,12 @@ ShaderVariable PackSnorm4x8(ThreadState &state, uint32_t, const rdcarray &pa uint32_t packed = 0; // The v operand must be a vector of 4 components whose type is a 32-bit floating-point. - packed |= (int32_t(RDCCLAMP(v.value.fv[0], -1.0f, 1.0f) * 127.0f) & 0xff) << 0; - packed |= (int32_t(RDCCLAMP(v.value.fv[1], -1.0f, 1.0f) * 127.0f) & 0xff) << 8; - packed |= (int32_t(RDCCLAMP(v.value.fv[2], -1.0f, 1.0f) * 127.0f) & 0xff) << 16; - packed |= (int32_t(RDCCLAMP(v.value.fv[3], -1.0f, 1.0f) * 127.0f) & 0xff) << 24; + packed |= (int32_t(RDCCLAMP(v.value.f32v[0], -1.0f, 1.0f) * 127.0f) & 0xff) << 0; + packed |= (int32_t(RDCCLAMP(v.value.f32v[1], -1.0f, 1.0f) * 127.0f) & 0xff) << 8; + packed |= (int32_t(RDCCLAMP(v.value.f32v[2], -1.0f, 1.0f) * 127.0f) & 0xff) << 16; + packed |= (int32_t(RDCCLAMP(v.value.f32v[3], -1.0f, 1.0f) * 127.0f) & 0xff) << 24; - v.value.uv[0] = packed; + v.value.u32v[0] = packed; v.type = VarType::UInt; v.columns = 1; @@ -856,12 +856,12 @@ ShaderVariable PackUnorm4x8(ThreadState &state, uint32_t, const rdcarray &pa uint32_t packed = 0; // The v operand must be a vector of 4 components whose type is a 32-bit floating-point. - packed |= (uint32_t(RDCCLAMP(v.value.fv[0], 0.0f, 1.0f) * 255.0f) & 0xff) << 0; - packed |= (uint32_t(RDCCLAMP(v.value.fv[1], 0.0f, 1.0f) * 255.0f) & 0xff) << 8; - packed |= (uint32_t(RDCCLAMP(v.value.fv[2], 0.0f, 1.0f) * 255.0f) & 0xff) << 16; - packed |= (uint32_t(RDCCLAMP(v.value.fv[3], 0.0f, 1.0f) * 255.0f) & 0xff) << 24; + packed |= (uint32_t(RDCCLAMP(v.value.f32v[0], 0.0f, 1.0f) * 255.0f) & 0xff) << 0; + packed |= (uint32_t(RDCCLAMP(v.value.f32v[1], 0.0f, 1.0f) * 255.0f) & 0xff) << 8; + packed |= (uint32_t(RDCCLAMP(v.value.f32v[2], 0.0f, 1.0f) * 255.0f) & 0xff) << 16; + packed |= (uint32_t(RDCCLAMP(v.value.f32v[3], 0.0f, 1.0f) * 255.0f) & 0xff) << 24; - v.value.uv[0] = packed; + v.value.u32v[0] = packed; v.type = VarType::UInt; v.columns = 1; @@ -878,10 +878,10 @@ ShaderVariable PackSnorm2x16(ThreadState &state, uint32_t, const rdcarray &p uint32_t packed = 0; // The v operand must be a vector of 4 components whose type is a 32-bit floating-point. - packed |= (int32_t(RDCCLAMP(v.value.fv[0], -1.0f, 1.0f) * 32767.0f) & 0xffff) << 0; - packed |= (int32_t(RDCCLAMP(v.value.fv[1], -1.0f, 1.0f) * 32767.0f) & 0xffff) << 16; + packed |= (int32_t(RDCCLAMP(v.value.f32v[0], -1.0f, 1.0f) * 32767.0f) & 0xffff) << 0; + packed |= (int32_t(RDCCLAMP(v.value.f32v[1], -1.0f, 1.0f) * 32767.0f) & 0xffff) << 16; - v.value.uv[0] = packed; + v.value.u32v[0] = packed; v.type = VarType::UInt; v.columns = 1; @@ -898,10 +898,10 @@ ShaderVariable PackUnorm2x16(ThreadState &state, uint32_t, const rdcarray &p uint32_t packed = 0; // The v operand must be a vector of 4 components whose type is a 32-bit floating-point. - packed |= (uint32_t(RDCCLAMP(v.value.fv[0], 0.0f, 1.0f) * 65535.0f) & 0xffff) << 0; - packed |= (uint32_t(RDCCLAMP(v.value.fv[1], 0.0f, 1.0f) * 65535.0f) & 0xffff) << 16; + packed |= (uint32_t(RDCCLAMP(v.value.f32v[0], 0.0f, 1.0f) * 65535.0f) & 0xffff) << 0; + packed |= (uint32_t(RDCCLAMP(v.value.f32v[1], 0.0f, 1.0f) * 65535.0f) & 0xffff) << 16; - v.value.uv[0] = packed; + v.value.u32v[0] = packed; v.type = VarType::UInt; v.columns = 1; @@ -918,10 +918,10 @@ ShaderVariable PackHalf2x16(ThreadState &state, uint32_t, const rdcarray &pa uint32_t packed = 0; // The v operand must be a vector of 4 components whose type is a 32-bit floating-point. - packed |= ConvertToHalf(v.value.fv[0]) << 0; - packed |= ConvertToHalf(v.value.fv[1]) << 16; + packed |= ConvertToHalf(v.value.f32v[0]) << 0; + packed |= ConvertToHalf(v.value.f32v[1]) << 16; - v.value.uv[0] = packed; + v.value.u32v[0] = packed; v.type = VarType::UInt; v.columns = 1; @@ -936,7 +936,7 @@ ShaderVariable PackDouble2x32(ThreadState &state, uint32_t, const rdcarray & ShaderVariable v = state.GetSrc(params[0]); // u64 is aliased with the double, so we just OR together - v.value.u64v[0] = uint64_t(v.value.uv[0]) | (uint64_t(v.value.uv[1]) << 32); + v.value.u64v[0] = uint64_t(v.value.u32v[0]) | (uint64_t(v.value.u32v[1]) << 32); v.type = VarType::Double; v.columns = 1; @@ -950,13 +950,13 @@ ShaderVariable UnpackSnorm4x8(ThreadState &state, uint32_t, const rdcarray & ShaderVariable v = state.GetSrc(params[0]); - uint32_t packed = v.value.uv[0]; + uint32_t packed = v.value.u32v[0]; // The v operand must be a vector of 4 components whose type is a 32-bit floating-point. - v.value.fv[0] = RDCCLAMP(float(int8_t((packed >> 0) & 0xff)) / 127.0f, -1.0f, 1.0f); - v.value.fv[1] = RDCCLAMP(float(int8_t((packed >> 8) & 0xff)) / 127.0f, -1.0f, 1.0f); - v.value.fv[2] = RDCCLAMP(float(int8_t((packed >> 16) & 0xff)) / 127.0f, -1.0f, 1.0f); - v.value.fv[3] = RDCCLAMP(float(int8_t((packed >> 24) & 0xff)) / 127.0f, -1.0f, 1.0f); + v.value.f32v[0] = RDCCLAMP(float(int8_t((packed >> 0) & 0xff)) / 127.0f, -1.0f, 1.0f); + v.value.f32v[1] = RDCCLAMP(float(int8_t((packed >> 8) & 0xff)) / 127.0f, -1.0f, 1.0f); + v.value.f32v[2] = RDCCLAMP(float(int8_t((packed >> 16) & 0xff)) / 127.0f, -1.0f, 1.0f); + v.value.f32v[3] = RDCCLAMP(float(int8_t((packed >> 24) & 0xff)) / 127.0f, -1.0f, 1.0f); v.type = VarType::Float; v.columns = 4; @@ -970,12 +970,12 @@ ShaderVariable UnpackUnorm4x8(ThreadState &state, uint32_t, const rdcarray & ShaderVariable v = state.GetSrc(params[0]); - uint32_t packed = v.value.uv[0]; + uint32_t packed = v.value.u32v[0]; - v.value.fv[0] = float((packed >> 0) & 0xff) / 255.0f; - v.value.fv[1] = float((packed >> 8) & 0xff) / 255.0f; - v.value.fv[2] = float((packed >> 16) & 0xff) / 255.0f; - v.value.fv[3] = float((packed >> 24) & 0xff) / 255.0f; + v.value.f32v[0] = float((packed >> 0) & 0xff) / 255.0f; + v.value.f32v[1] = float((packed >> 8) & 0xff) / 255.0f; + v.value.f32v[2] = float((packed >> 16) & 0xff) / 255.0f; + v.value.f32v[3] = float((packed >> 24) & 0xff) / 255.0f; v.type = VarType::Float; v.columns = 4; @@ -989,10 +989,10 @@ ShaderVariable UnpackSnorm2x16(ThreadState &state, uint32_t, const rdcarray ShaderVariable v = state.GetSrc(params[0]); - uint32_t packed = v.value.uv[0]; + uint32_t packed = v.value.u32v[0]; - v.value.fv[0] = RDCCLAMP(float(int16_t((packed >> 0) & 0xffff)) / 32767.0f, -1.0f, 1.0f); - v.value.fv[1] = RDCCLAMP(float(int16_t((packed >> 16) & 0xffff)) / 32767.0f, -1.0f, 1.0f); + v.value.f32v[0] = RDCCLAMP(float(int16_t((packed >> 0) & 0xffff)) / 32767.0f, -1.0f, 1.0f); + v.value.f32v[1] = RDCCLAMP(float(int16_t((packed >> 16) & 0xffff)) / 32767.0f, -1.0f, 1.0f); v.type = VarType::Float; v.columns = 2; @@ -1006,10 +1006,10 @@ ShaderVariable UnpackUnorm2x16(ThreadState &state, uint32_t, const rdcarray ShaderVariable v = state.GetSrc(params[0]); - uint32_t packed = v.value.uv[0]; + uint32_t packed = v.value.u32v[0]; - v.value.fv[0] = float((packed >> 0) & 0xffff) / 65535.0f; - v.value.fv[1] = float((packed >> 16) & 0xffff) / 65535.0f; + v.value.f32v[0] = float((packed >> 0) & 0xffff) / 65535.0f; + v.value.f32v[1] = float((packed >> 16) & 0xffff) / 65535.0f; v.type = VarType::Float; v.columns = 2; @@ -1023,10 +1023,10 @@ ShaderVariable UnpackHalf2x16(ThreadState &state, uint32_t, const rdcarray & ShaderVariable v = state.GetSrc(params[0]); - uint32_t packed = v.value.uv[0]; + uint32_t packed = v.value.u32v[0]; - v.value.fv[0] = ConvertFromHalf((packed >> 0) & 0xffff); - v.value.fv[1] = ConvertFromHalf((packed >> 16) & 0xffff); + v.value.f32v[0] = ConvertFromHalf((packed >> 0) & 0xffff); + v.value.f32v[1] = ConvertFromHalf((packed >> 16) & 0xffff); v.type = VarType::Float; v.columns = 2; @@ -1042,8 +1042,8 @@ ShaderVariable UnpackDouble2x32(ThreadState &state, uint32_t, const rdcarray // u64 is aliased with the double, so we just OR together uint64_t doubleUint = v.value.u64v[0]; - v.value.uv[0] = (doubleUint >> 0) & 0xFFFFFFFFU; - v.value.uv[1] = (doubleUint >> 32) & 0xFFFFFFFFU; + v.value.u32v[0] = (doubleUint >> 0) & 0xFFFFFFFFU; + v.value.u32v[1] = (doubleUint >> 32) & 0xFFFFFFFFU; v.type = VarType::UInt; v.columns = 2; @@ -1130,7 +1130,7 @@ ShaderVariable FindILsb(ThreadState &state, uint32_t, const rdcarray ¶ms // This instruction is currently limited to 32-bit width components. for(uint8_t c = 0; c < x.columns; c++) - x.value.iv[c] = x.value.uv[c] == 0 ? -1 : Bits::CountTrailingZeroes(x.value.uv[c]); + x.value.s32v[c] = x.value.u32v[c] == 0 ? -1 : Bits::CountTrailingZeroes(x.value.u32v[c]); return x; } @@ -1144,12 +1144,12 @@ ShaderVariable FindSMsb(ThreadState &state, uint32_t, const rdcarray ¶ms // This instruction is currently limited to 32-bit width components. for(uint8_t c = 0; c < x.columns; c++) { - if(x.value.iv[c] == 0 || x.value.iv[c] == -1) - x.value.iv[c] = -1; - else if(x.value.iv[c] >= 0) - x.value.uv[c] = 31 - Bits::CountLeadingZeroes(x.value.uv[c]); + if(x.value.s32v[c] == 0 || x.value.s32v[c] == -1) + x.value.s32v[c] = -1; + else if(x.value.s32v[c] >= 0) + x.value.u32v[c] = 31 - Bits::CountLeadingZeroes(x.value.u32v[c]); else - x.value.uv[c] = 31 - Bits::CountLeadingZeroes(~x.value.uv[c]); + x.value.u32v[c] = 31 - Bits::CountLeadingZeroes(~x.value.u32v[c]); } return x; @@ -1164,7 +1164,7 @@ ShaderVariable FindUMsb(ThreadState &state, uint32_t, const rdcarray ¶ms // This instruction is currently limited to 32-bit width components. for(uint8_t c = 0; c < x.columns; c++) { - x.value.iv[c] = x.value.iv[c] == 0 ? -1 : 31 - Bits::CountLeadingZeroes(x.value.uv[c]); + x.value.s32v[c] = x.value.s32v[c] == 0 ? -1 : 31 - Bits::CountLeadingZeroes(x.value.u32v[c]); } return x; @@ -1235,7 +1235,7 @@ ShaderVariable GPUOp(ThreadState &state, uint32_t instruction, const rdcarrayCalculateMathOp(state, (GLSLstd450)instruction, paramVars, ret)) - memset(ret.value.u64v, 0, sizeof(ret.value.u64v)); + memset(&ret.value, 0, sizeof(ret.value)); return ret; } diff --git a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp index d512635b4..96380ac9a 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp @@ -93,14 +93,14 @@ static uint32_t VarByteSize(const ShaderVariable &var) static void *VarElemPointer(ShaderVariable &var, uint32_t comp) { RDCASSERTNOTEQUAL(var.type, VarType::Unknown); - byte *ret = (byte *)var.value.u64v; + byte *ret = (byte *)var.value.u8v.data(); return ret + comp * VarTypeByteSize(var.type); } static const void *VarElemPointer(const ShaderVariable &var, uint32_t comp) { RDCASSERTNOTEQUAL(var.type, VarType::Unknown); - const byte *ret = (const byte *)var.value.u64v; + const byte *ret = (const byte *)var.value.u8v.data(); return ret + comp * VarTypeByteSize(var.type); } @@ -667,7 +667,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s else { // make it obvious when uninitialised outputs are written - memset(var.value.u64v, 0xcc, sizeof(var.value.u64v)); + memset(&var.value, 0xcc, sizeof(var.value)); } if(sourceName != rawName) @@ -815,7 +815,8 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s // non-matrix case is simple, just read the size of the variable if(var.rows == 1) { - this->apiWrapper->ReadBufferValue(bindpoint, offset, VarByteSize(var), var.value.uv); + this->apiWrapper->ReadBufferValue(bindpoint, offset, VarByteSize(var), + var.value.u8v.data()); } else { @@ -1016,7 +1017,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s if(!var.members.empty()) return; - memset(var.value.u64v, 0xcc, sizeof(var.value.u64v)); + memset(&var.value, 0xcc, sizeof(var.value)); }; WalkVariable(decorations[v.id], dataTypes[type.InnerType()], ~0U, var, @@ -1949,7 +1950,7 @@ void Debugger::AllocateVariable(Id id, Id typeId, ShaderVariable &outVar) return; // make it obvious when uninitialised values are used - memset(var.value.u64v, 0xcc, sizeof(var.value.u64v)); + memset(&var.value, 0xcc, sizeof(var.value)); }; WalkVariable(Decorations(), dataTypes[dataTypes[typeId].InnerType()], ~0U, @@ -2161,10 +2162,10 @@ static void ApplyDerivative(uint32_t activeLaneIndex, uint32_t quadIndex, FloatT #define ADD_DERIV(src) \ for(int i = 0; i < 4; i++) \ - dst[i] += ((FloatType *)src.value.u64v)[i]; + dst[i] += comp(src, i); #define SUB_DERIV(src) \ for(int i = 0; i < 4; i++) \ - dst[i] -= ((FloatType *)src.value.u64v)[i]; + dst[i] -= comp(src, i); switch(activeLaneIndex) { @@ -2280,12 +2281,12 @@ uint32_t Debugger::ApplyDerivatives(uint32_t quadIndex, const Decorations &curDe apiWrapper->GetDerivative(builtin, location, component, outVar.type); if(outVar.type == VarType::Float) - ApplyDerivative(activeLaneIndex, quadIndex, outVar.value.fv, derivs); + ApplyDerivative(activeLaneIndex, quadIndex, outVar.value.f32v.data(), derivs); else if(outVar.type == VarType::Half) ApplyDerivative(activeLaneIndex, quadIndex, - (half_float::half *)outVar.value.u16v, derivs); + (half_float::half *)outVar.value.u16v.data(), derivs); else if(outVar.type == VarType::Double) - ApplyDerivative(activeLaneIndex, quadIndex, outVar.value.dv, derivs); + ApplyDerivative(activeLaneIndex, quadIndex, outVar.value.f64v.data(), derivs); } // each row consumes a new location diff --git a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp index dd1251322..af69146ad 100644 --- a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp @@ -171,7 +171,7 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint, // if we *still* have nothing, just stringise the id itself return StringFormat::Fmt("_%u", id.value()); }; - auto constIntVal = [this](Id id) { return EvaluateConstant(id, {}).value.u.x; }; + auto constIntVal = [this](Id id) { return EvaluateConstant(id, {}).value.u32v[0]; }; auto declName = [this, &idName, &usedNames, &dynamicNames](Id typeId, Id id) -> rdcstr { if(typeId == Id()) return idName(id); @@ -435,15 +435,15 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint, switch(type.scalar().Type()) { case VarType::Float: - case VarType::Half: ret += ToStr(value.f.x); break; - case VarType::Double: ret += ToStr(value.d.x); break; + case VarType::Half: ret += ToStr(value.f32v[0]); break; + case VarType::Double: ret += ToStr(value.f64v[0]); break; case VarType::SInt: case VarType::SShort: - case VarType::SByte: ret += ToStr(value.i.x); break; - case VarType::Bool: ret += value.u.x ? "true" : "false"; break; + case VarType::SByte: ret += ToStr(value.s32v[0]); break; + case VarType::Bool: ret += value.u32v[0] ? "true" : "false"; break; case VarType::UInt: case VarType::UShort: - case VarType::UByte: ret += ToStr(value.u.x); break; + case VarType::UByte: ret += ToStr(value.u32v[0]); break; case VarType::SLong: ret += ToStr(value.s64v[0]); break; case VarType::Unknown: case VarType::GPUPointer: @@ -1449,7 +1449,7 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint, // if it's a non-specialised constant, get its value if(constants.find(decoded.indexes[i]) != constants.end() && specConstants.find(decoded.indexes[i]) == specConstants.end()) - idx = EvaluateConstant(decoded.indexes[i], {}).value.i.x; + idx = EvaluateConstant(decoded.indexes[i], {}).value.s32v[0]; // if it's a struct we must have an OpConstant to use, if it's a vector and we did get a // constant then do better than a basic array index syntax. @@ -1613,20 +1613,20 @@ rdcstr Reflector::StringiseConstant(rdcspv::Id id) const if(type.type == DataType::ScalarType) { if(type.scalar().type == Op::TypeBool) - return value.value.u.x ? "true" : "false"; + return value.value.u32v[0] ? "true" : "false"; switch(value.type) { case VarType::Float: - case VarType::Half: return ToStr(value.value.f.x); - case VarType::Double: return ToStr(value.value.d.x); + case VarType::Half: return ToStr(value.value.f32v[0]); + case VarType::Double: return ToStr(value.value.f64v[0]); case VarType::SInt: case VarType::SShort: - case VarType::SByte: return ToStr(value.value.i.x); - case VarType::Bool: return value.value.u.x ? "true" : "false"; + case VarType::SByte: return ToStr(value.value.s32v[0]); + case VarType::Bool: return value.value.u32v[0] ? "true" : "false"; case VarType::UInt: case VarType::UShort: - case VarType::UByte: return ToStr(value.value.u.x); + case VarType::UByte: return ToStr(value.value.u32v[0]); case VarType::SLong: return ToStr(value.value.s64v[0]); case VarType::Unknown: case VarType::GPUPointer: @@ -1645,16 +1645,16 @@ rdcstr Reflector::StringiseConstant(rdcspv::Id id) const switch(value.type) { case VarType::Float: - case VarType::Half: ret += ToStr(value.value.fv[i]); break; - case VarType::Double: ret += ToStr(value.value.dv[i]); break; + case VarType::Half: ret += ToStr(value.value.f32v[i]); break; + case VarType::Double: ret += ToStr(value.value.f64v[i]); break; case VarType::SInt: case VarType::SShort: - case VarType::SByte: ret += ToStr(value.value.iv[i]); break; + case VarType::SByte: ret += ToStr(value.value.s32v[i]); break; case VarType::UInt: case VarType::UShort: - case VarType::UByte: ret += ToStr(value.value.uv[i]); break; + case VarType::UByte: ret += ToStr(value.value.u32v[i]); break; case VarType::SLong: ret += ToStr(value.value.s64v[i]); break; - case VarType::Bool: return value.value.u.x ? "true" : "false"; + case VarType::Bool: return value.value.u32v[0] ? "true" : "false"; case VarType::Unknown: case VarType::GPUPointer: case VarType::ConstantBlock: diff --git a/renderdoc/driver/shaders/spirv/spirv_processor.cpp b/renderdoc/driver/shaders/spirv/spirv_processor.cpp index 5b785f10f..7fc08602b 100644 --- a/renderdoc/driver/shaders/spirv/spirv_processor.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_processor.cpp @@ -47,7 +47,7 @@ static void ConstructCompositeConstant(ShaderVariable &v, const rdcarray 32) { - v.value.uv[1] = it.word(4); + v.value.u32v[1] = it.word(4); } else { @@ -660,11 +660,11 @@ void Processor::RegisterOp(Iter it) if(type.scalar().signedness && type.scalar().width < 16) { // is the top bit set? - if(v.value.uv[0] & (1 << (type.scalar().width - 1))) + if(v.value.u32v[0] & (1 << (type.scalar().width - 1))) { uint32_t mask = 0xFFFFFFFFU >> (32 - type.scalar().width); - v.value.uv[0] |= ~mask & ~0U; + v.value.u32v[0] |= ~mask & ~0U; } } } @@ -960,7 +960,7 @@ ShaderVariable Processor::MakeNULL(const DataType &type, uint64_t value) else if(type.type == DataType::ArrayType) { // TODO handle spec constant array length here... somehow - v.members.resize(EvaluateConstant(type.length, {}).value.u.x); + v.members.resize(EvaluateConstant(type.length, {}).value.u32v[0]); for(size_t i = 0; i < v.members.size(); i++) { v.members[i] = MakeNULL(dataTypes[type.InnerType()], value); @@ -1022,7 +1022,7 @@ ShaderVariable Processor::EvaluateConstant(Id constID, const rdcarrayexecutionModes.localSizeId.x != Id()) { reflection.dispatchThreadsDimension[0] = - EvaluateConstant(e.executionModes.localSizeId.x, specInfo).value.u.x; + EvaluateConstant(e.executionModes.localSizeId.x, specInfo).value.u32v[0]; reflection.dispatchThreadsDimension[1] = - EvaluateConstant(e.executionModes.localSizeId.y, specInfo).value.u.x; + EvaluateConstant(e.executionModes.localSizeId.y, specInfo).value.u32v[0]; reflection.dispatchThreadsDimension[2] = - EvaluateConstant(e.executionModes.localSizeId.z, specInfo).value.u.x; + EvaluateConstant(e.executionModes.localSizeId.z, specInfo).value.u32v[0]; } else if(e.executionModes.localSize.x > 0) { @@ -660,7 +660,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st RDCASSERT(c.children.size() == 3); for(size_t i = 0; i < c.children.size() && i < 3; i++) reflection.dispatchThreadsDimension[i] = - EvaluateConstant(c.children[i], specInfo).value.u.x; + EvaluateConstant(c.children[i], specInfo).value.u32v[0]; } } } @@ -721,7 +721,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st // save top-level children referenced in structs if(dataTypes[dataTypes[idTypes[access.base]].InnerType()].type == DataType::StructType) usedStructChildren[access.base].insert( - EvaluateConstant(access.indexes[0], specInfo).value.u.x); + EvaluateConstant(access.indexes[0], specInfo).value.u32v[0]); } if(it.opcode() == Op::FunctionCall) @@ -879,7 +879,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st isArray = true; // runtime arrays have no length if(varType->length != Id()) - arraySize = EvaluateConstant(varType->length, specInfo).value.u.x; + arraySize = EvaluateConstant(varType->length, specInfo).value.u32v[0]; else arraySize = ~0U; varType = &dataTypes[varType->InnerType()]; @@ -1386,7 +1386,7 @@ void Reflector::MakeConstantBlockVariable(ShaderConstant &outConst, if(curType->type == DataType::ArrayType) { outConst.type.descriptor.elements = - curType->length != Id() ? EvaluateConstant(curType->length, specInfo).value.u.x : ~0U; + curType->length != Id() ? EvaluateConstant(curType->length, specInfo).value.u32v[0] : ~0U; if(varDecorations.arrayStride != ~0U) { @@ -1521,7 +1521,7 @@ void Reflector::AddSignatureParameter(const bool isInput, const ShaderStage stag uint32_t arraySize = 1; if(varType->type == DataType::ArrayType) { - arraySize = EvaluateConstant(varType->length, specInfo).value.u.x; + arraySize = EvaluateConstant(varType->length, specInfo).value.u32v[0]; isArray = true; varType = &dataTypes[varType->InnerType()]; diff --git a/renderdoc/driver/shaders/spirv/var_dispatch_helpers.h b/renderdoc/driver/shaders/spirv/var_dispatch_helpers.h index bdb9f937e..995700d8d 100644 --- a/renderdoc/driver/shaders/spirv/var_dispatch_helpers.h +++ b/renderdoc/driver/shaders/spirv/var_dispatch_helpers.h @@ -56,13 +56,13 @@ inline half_float::half &comp(ShaderVariable &var, uint32_t c) template <> inline float &comp(ShaderVariable &var, uint32_t c) { - return var.value.fv[c]; + return var.value.f32v[c]; } template <> inline double &comp(ShaderVariable &var, uint32_t c) { - return var.value.dv[c]; + return var.value.f64v[c]; } template @@ -80,13 +80,13 @@ inline half_float::half comp(const ShaderVariable &var, uint32 template <> inline float comp(const ShaderVariable &var, uint32_t c) { - return var.value.fv[c]; + return var.value.f32v[c]; } template <> inline double comp(const ShaderVariable &var, uint32_t c) { - return var.value.dv[c]; + return var.value.f64v[c]; } #define INT_COMP(type, member) \ @@ -105,8 +105,8 @@ INT_COMP(uint8_t, u8v); INT_COMP(int8_t, s8v); INT_COMP(uint16_t, u16v); INT_COMP(int16_t, s16v); -INT_COMP(uint32_t, uv); -INT_COMP(int32_t, iv); +INT_COMP(uint32_t, u32v); +INT_COMP(int32_t, s32v); INT_COMP(uint64_t, u64v); INT_COMP(int64_t, s64v); @@ -114,11 +114,11 @@ INT_COMP(int64_t, s64v); inline float floatComp(const ShaderVariable &var, uint32_t c) { if(var.type == VarType::Float) - return var.value.fv[c]; + return var.value.f32v[c]; else if(var.type == VarType::Half) return ConvertFromHalf(var.value.u16v[c]); else if(var.type == VarType::Double) - return (float)var.value.dv[c]; + return (float)var.value.f64v[c]; else return 0.0f; } @@ -127,7 +127,7 @@ inline uint32_t uintComp(const ShaderVariable &var, uint32_t c) { uint32_t byteSize = VarTypeByteSize(var.type); if(byteSize == 4) - return var.value.uv[c]; + return var.value.u32v[c]; else if(byteSize == 2) return var.value.u16v[c]; else if(byteSize == 8) @@ -142,7 +142,7 @@ inline int32_t intComp(const ShaderVariable &var, uint32_t c) { uint32_t byteSize = VarTypeByteSize(var.type); if(byteSize == 4) - return var.value.iv[c]; + return var.value.s32v[c]; else if(byteSize == 2) return var.value.s16v[c]; else if(byteSize == 8) @@ -156,18 +156,18 @@ inline int32_t intComp(const ShaderVariable &var, uint32_t c) inline void setFloatComp(ShaderVariable &var, uint32_t c, float f) { if(var.type == VarType::Float) - var.value.fv[c] = f; + var.value.f32v[c] = f; else if(var.type == VarType::Half) var.value.u16v[c] = ConvertToHalf(f); else if(var.type == VarType::Double) - var.value.dv[c] = f; + var.value.f64v[c] = f; } inline void setUintComp(ShaderVariable &var, uint32_t c, uint32_t u) { uint32_t byteSize = VarTypeByteSize(var.type); if(byteSize == 4) - var.value.uv[c] = u; + var.value.u32v[c] = u; else if(byteSize == 2) var.value.u16v[c] = u & 0xffffu; else if(byteSize == 8) @@ -180,7 +180,7 @@ inline void setIntComp(ShaderVariable &var, uint32_t c, int32_t i) { uint32_t byteSize = VarTypeByteSize(var.type); if(byteSize == 4) - var.value.iv[c] = i; + var.value.s32v[c] = i; else if(byteSize == 2) var.value.s16v[c] = (int16_t)i; else if(byteSize == 8) @@ -194,11 +194,11 @@ inline void set0001(ShaderVariable &result) RDCEraseEl(result.value); if(result.type == VarType::Float) - result.value.fv[3] = 1.0f; + result.value.f32v[3] = 1.0f; else if(result.type == VarType::Half) result.value.u16v[3] = ConvertToHalf(1.0f); else if(result.type == VarType::Double) - result.value.dv[3] = 1.0; + result.value.f64v[3] = 1.0; else setUintComp(result, 3, 1); } @@ -212,7 +212,8 @@ inline void copyComp(ShaderVariable &dst, uint32_t dstComp, const ShaderVariable type = src.type; } const uint32_t sz = VarTypeByteSize(type); - memcpy(((byte *)dst.value.u64v) + sz * dstComp, ((byte *)src.value.u64v) + sz * srcComp, sz); + memcpy(((byte *)dst.value.u8v.data()) + sz * dstComp, + ((byte *)src.value.u8v.data()) + sz * srcComp, sz); } #define IMPL_FOR_FLOAT_TYPES_FOR_TYPE(impl, type) \ diff --git a/renderdoc/driver/vulkan/vk_common.cpp b/renderdoc/driver/vulkan/vk_common.cpp index 18202fbdc..4e1804bc7 100644 --- a/renderdoc/driver/vulkan/vk_common.cpp +++ b/renderdoc/driver/vulkan/vk_common.cpp @@ -657,24 +657,18 @@ AddressMode MakeAddressMode(VkSamplerAddressMode addr) return AddressMode::Wrap; } -void MakeBorderColor(VkBorderColor border, FloatVector *BorderColor) +void MakeBorderColor(VkBorderColor border, rdcfixedarray &BorderColor) { // we don't distinguish float/int, assume it matches switch(border) { case VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK: - case VK_BORDER_COLOR_INT_TRANSPARENT_BLACK: - *BorderColor = FloatVector(0.0f, 0.0f, 0.0f, 0.0f); - break; + case VK_BORDER_COLOR_INT_TRANSPARENT_BLACK: BorderColor = {0.0f, 0.0f, 0.0f, 0.0f}; break; case VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK: - case VK_BORDER_COLOR_INT_OPAQUE_BLACK: - *BorderColor = FloatVector(0.0f, 0.0f, 0.0f, 1.0f); - break; + case VK_BORDER_COLOR_INT_OPAQUE_BLACK: BorderColor = {0.0f, 0.0f, 0.0f, 1.0f}; break; case VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE: - case VK_BORDER_COLOR_INT_OPAQUE_WHITE: - *BorderColor = FloatVector(1.0f, 1.0f, 1.0f, 1.0f); - break; - default: memset(BorderColor, 0, sizeof(FloatVector)); break; + case VK_BORDER_COLOR_INT_OPAQUE_WHITE: BorderColor = {1.0f, 1.0f, 1.0f, 1.0f}; break; + default: BorderColor = {0.0f, 0.0f, 0.0f, 0.0f}; break; } } diff --git a/renderdoc/driver/vulkan/vk_common.h b/renderdoc/driver/vulkan/vk_common.h index cb6b637d0..7208ed6d0 100644 --- a/renderdoc/driver/vulkan/vk_common.h +++ b/renderdoc/driver/vulkan/vk_common.h @@ -78,7 +78,7 @@ VkFormat MakeVkFormat(ResourceFormat fmt); Topology MakePrimitiveTopology(VkPrimitiveTopology Topo, uint32_t patchControlPoints); VkPrimitiveTopology MakeVkPrimitiveTopology(Topology Topo); AddressMode MakeAddressMode(VkSamplerAddressMode addr); -void MakeBorderColor(VkBorderColor border, FloatVector *BorderColor); +void MakeBorderColor(VkBorderColor border, rdcfixedarray &BorderColor); CompareFunction MakeCompareFunc(VkCompareOp func); FilterMode MakeFilterMode(VkFilter f); TextureFilter MakeFilter(VkFilter minFilter, VkFilter magFilter, VkSamplerMipmapMode mipmapMode, diff --git a/renderdoc/driver/vulkan/vk_pixelhistory.cpp b/renderdoc/driver/vulkan/vk_pixelhistory.cpp index 2f0d44613..2abd62eef 100644 --- a/renderdoc/driver/vulkan/vk_pixelhistory.cpp +++ b/renderdoc/driver/vulkan/vk_pixelhistory.cpp @@ -2425,7 +2425,7 @@ struct VulkanPixelHistoryPerFragmentCallback : VulkanPixelHistoryCallback clearAtts[0].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; clearAtts[0].colorAttachment = colorOutputIndex; - memcpy(clearAtts[0].clearValue.color.float32, premod.col.floatValue, + memcpy(clearAtts[0].clearValue.color.float32, premod.col.floatValue.data(), sizeof(clearAtts[0].clearValue.color)); clearAtts[1].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; @@ -3175,7 +3175,7 @@ void UpdateTestsFailed(const TestsFailedCallback *tfCb, uint32_t eventId, uint32 void FillInColor(ResourceFormat fmt, const PixelHistoryValue &value, ModificationValue &mod) { FloatVector v4 = DecodeFormattedComponents(fmt, value.color); - memcpy(mod.col.floatValue, &v4, sizeof(v4)); + memcpy(mod.col.floatValue.data(), &v4, sizeof(v4)); } float GetDepthValue(VkFormat depthFormat, const PixelHistoryValue &value) diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index 9222a8453..ca69ad9e8 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -1395,7 +1395,7 @@ void VulkanReplay::SavePipelineState(uint32_t eventId) m_VulkanPipelineState.colorBlend.blends[i].writeMask = p.attachments[i].channelWriteMask; } - memcpy(m_VulkanPipelineState.colorBlend.blendFactor, state.blendConst, sizeof(float) * 4); + m_VulkanPipelineState.colorBlend.blendFactor = state.blendConst; // Depth Stencil m_VulkanPipelineState.depthStencil.depthTestEnable = state.depthTestEnable != VK_FALSE; @@ -1781,7 +1781,7 @@ void VulkanReplay::SavePipelineState(uint32_t eventId) el.compareFunction = MakeCompareFunc(sampl.compareOp); el.minLOD = sampl.minLod; el.maxLOD = sampl.maxLod; - MakeBorderColor(sampl.borderColor, (FloatVector *)el.borderColor); + MakeBorderColor(sampl.borderColor, el.borderColor); el.unnormalized = sampl.unnormalizedCoordinates; if(sampl.ycbcr != ResourceId()) @@ -1807,7 +1807,7 @@ void VulkanReplay::SavePipelineState(uint32_t eventId) } else { - memcpy(el.borderColor, sampl.customBorderColor.float32, sizeof(Vec4f)); + el.borderColor = sampl.customBorderColor.float32; } } } diff --git a/renderdoc/driver/vulkan/vk_shaderdebug.cpp b/renderdoc/driver/vulkan/vk_shaderdebug.cpp index 7d2959efe..bb6fcf06e 100644 --- a/renderdoc/driver/vulkan/vk_shaderdebug.cpp +++ b/renderdoc/driver/vulkan/vk_shaderdebug.cpp @@ -393,7 +393,7 @@ public: } RDCASSERTEQUAL(data.texelSize, VarTypeByteSize(output.type) * output.columns); - memcpy(output.value.u64v, data.texel(coords, sample), data.texelSize); + memcpy(output.value.u8v.data(), data.texel(coords, sample), data.texelSize); return true; } @@ -421,7 +421,7 @@ public: } RDCASSERTEQUAL(data.texelSize, VarTypeByteSize(value.type) * value.columns); - memcpy(data.texel(coords, sample), value.value.u64v, data.texelSize); + memcpy(data.texel(coords, sample), value.value.u8v.data(), data.texelSize); return true; } @@ -612,14 +612,14 @@ public: { case rdcspv::Op::ImageQueryLevels: { - output.value.u.x = viewProps.range.levelCount; + output.value.u32v[0] = viewProps.range.levelCount; if(viewProps.range.levelCount == VK_REMAINING_MIP_LEVELS) - output.value.u.x = imageProps.mipLevels - viewProps.range.baseMipLevel; + output.value.u32v[0] = imageProps.mipLevels - viewProps.range.baseMipLevel; return true; } case rdcspv::Op::ImageQuerySamples: { - output.value.u.x = (uint32_t)imageProps.samples; + output.value.u32v[0] = (uint32_t)imageProps.samples; return true; } case rdcspv::Op::ImageQuerySize: @@ -704,12 +704,12 @@ public: { const ShaderVariable &biasVar = lane.GetSrc(operands.bias); - float bias = biasVar.value.f.x; + float bias = biasVar.value.f32v[0]; // silently cast parameters to 32-bit floats if(biasVar.type == VarType::Half) bias = ConvertFromHalf(biasVar.value.u16v[0]); else if(biasVar.type == VarType::Double) - bias = (float)biasVar.value.dv[0]; + bias = (float)biasVar.value.f64v[0]; if(bias != 0.0f) { @@ -877,7 +877,7 @@ public: if(uv.type == VarType::Float) { for(int i = 0; i < coords; i++) - uniformParams.uvwa[i] = uv.value.fv[i]; + uniformParams.uvwa[i] = uv.value.f32v[i]; } else if(uv.type == VarType::Half) { @@ -887,11 +887,11 @@ public: else if(uv.type == VarType::Double) { for(int i = 0; i < coords; i++) - uniformParams.uvwa[i] = (float)uv.value.dv[i]; + uniformParams.uvwa[i] = (float)uv.value.f64v[i]; } if(useCompare) - uniformParams.compare = compare.value.f.x; + uniformParams.compare = compare.value.f32v[0]; constParams.gatherChannel = gatherChannel; @@ -909,24 +909,24 @@ public: { if(constOffsets.members[i].type == VarType::SByte) { - constOffsets.members[i].value.i.x = constOffsets.members[i].value.s8v[0]; - constOffsets.members[i].value.i.y = constOffsets.members[i].value.s8v[1]; + constOffsets.members[i].value.s32v[0] = constOffsets.members[i].value.s8v[0]; + constOffsets.members[i].value.s32v[1] = constOffsets.members[i].value.s8v[1]; } else if(constOffsets.members[i].type == VarType::SShort) { - constOffsets.members[i].value.i.x = constOffsets.members[i].value.s16v[0]; - constOffsets.members[i].value.i.y = constOffsets.members[i].value.s16v[1]; + constOffsets.members[i].value.s32v[0] = constOffsets.members[i].value.s16v[0]; + constOffsets.members[i].value.s32v[1] = constOffsets.members[i].value.s16v[1]; } } - constParams.gatherOffsets.u0 = constOffsets.members[0].value.i.x; - constParams.gatherOffsets.v0 = constOffsets.members[0].value.i.y; - constParams.gatherOffsets.u1 = constOffsets.members[1].value.i.x; - constParams.gatherOffsets.v1 = constOffsets.members[1].value.i.y; - constParams.gatherOffsets.u2 = constOffsets.members[2].value.i.x; - constParams.gatherOffsets.v2 = constOffsets.members[2].value.i.y; - constParams.gatherOffsets.u3 = constOffsets.members[3].value.i.x; - constParams.gatherOffsets.v3 = constOffsets.members[3].value.i.y; + constParams.gatherOffsets.u0 = constOffsets.members[0].value.s32v[0]; + constParams.gatherOffsets.v0 = constOffsets.members[0].value.s32v[1]; + constParams.gatherOffsets.u1 = constOffsets.members[1].value.s32v[0]; + constParams.gatherOffsets.v1 = constOffsets.members[1].value.s32v[1]; + constParams.gatherOffsets.u2 = constOffsets.members[2].value.s32v[0]; + constParams.gatherOffsets.v2 = constOffsets.members[2].value.s32v[1]; + constParams.gatherOffsets.u3 = constOffsets.members[3].value.s32v[0]; + constParams.gatherOffsets.v3 = constOffsets.members[3].value.s32v[1]; } if(operands.flags & rdcspv::ImageOperands::ConstOffset) @@ -937,16 +937,16 @@ public: for(uint8_t c = 0; c < constOffset.columns; c++) { if(constOffset.type == VarType::SByte) - constOffset.value.iv[c] = constOffset.value.s8v[c]; + constOffset.value.s32v[c] = constOffset.value.s8v[c]; else if(constOffset.type == VarType::SShort) - constOffset.value.iv[c] = constOffset.value.s16v[c]; + constOffset.value.s32v[c] = constOffset.value.s16v[c]; } - uniformParams.offset.x = constOffset.value.i.x; + uniformParams.offset.x = constOffset.value.s32v[0]; if(gradCoords >= 2) - uniformParams.offset.y = constOffset.value.i.y; + uniformParams.offset.y = constOffset.value.s32v[1]; if(gradCoords >= 3) - uniformParams.offset.z = constOffset.value.i.z; + uniformParams.offset.z = constOffset.value.s32v[2]; } else if(operands.flags & rdcspv::ImageOperands::Offset) { @@ -956,16 +956,16 @@ public: for(uint8_t c = 0; c < offset.columns; c++) { if(offset.type == VarType::SByte) - offset.value.iv[c] = offset.value.s8v[c]; + offset.value.s32v[c] = offset.value.s8v[c]; else if(offset.type == VarType::SShort) - offset.value.iv[c] = offset.value.s16v[c]; + offset.value.s32v[c] = offset.value.s16v[c]; } - uniformParams.offset.x = offset.value.i.x; + uniformParams.offset.x = offset.value.s32v[0]; if(gradCoords >= 2) - uniformParams.offset.y = offset.value.i.y; + uniformParams.offset.y = offset.value.s32v[1]; if(gradCoords >= 3) - uniformParams.offset.z = offset.value.i.z; + uniformParams.offset.z = offset.value.s32v[2]; } break; @@ -984,7 +984,7 @@ public: if(uv.type == VarType::Float) { for(int i = 0; i < coords; i++) - uniformParams.uvwa[i] = uv.value.fv[i]; + uniformParams.uvwa[i] = uv.value.f32v[i]; } else if(uv.type == VarType::Half) { @@ -994,7 +994,7 @@ public: else if(uv.type == VarType::Double) { for(int i = 0; i < coords; i++) - uniformParams.uvwa[i] = (float)uv.value.dv[i]; + uniformParams.uvwa[i] = (float)uv.value.f64v[i]; } if(proj) @@ -1005,11 +1005,11 @@ public: // do the divide ourselves rather than severely complicating the sample shader (as proj // variants need non-arrayed textures) - float q = uv.value.fv[coords]; + float q = uv.value.f32v[coords]; if(uv.type == VarType::Half) q = ConvertFromHalf(uv.value.u16v[coords]); else if(uv.type == VarType::Double) - q = (float)uv.value.dv[coords]; + q = (float)uv.value.f64v[coords]; uniformParams.uvwa[0] /= q; uniformParams.uvwa[1] /= q; @@ -1020,34 +1020,34 @@ public: { const ShaderVariable &minLodVar = lane.GetSrc(operands.minLod); - uniformParams.minlod = minLodVar.value.f.x; + uniformParams.minlod = minLodVar.value.f32v[0]; // silently cast parameters to 32-bit floats if(minLodVar.type == VarType::Half) uniformParams.minlod = ConvertFromHalf(minLodVar.value.u16v[0]); else if(minLodVar.type == VarType::Double) - uniformParams.minlod = (float)minLodVar.value.dv[0]; + uniformParams.minlod = (float)minLodVar.value.f64v[0]; } if(useCompare) { - uniformParams.compare = compare.value.f.x; + uniformParams.compare = compare.value.f32v[0]; // silently cast parameters to 32-bit floats if(compare.type == VarType::Half) uniformParams.compare = ConvertFromHalf(compare.value.u16v[0]); else if(compare.type == VarType::Double) - uniformParams.compare = (float)compare.value.dv[0]; + uniformParams.compare = (float)compare.value.f64v[0]; } if(operands.flags & rdcspv::ImageOperands::Lod) { const ShaderVariable &lodVar = lane.GetSrc(operands.lod); - uniformParams.lod = lodVar.value.f.x; + uniformParams.lod = lodVar.value.f32v[0]; // silently cast parameters to 32-bit floats if(lodVar.type == VarType::Half) uniformParams.lod = ConvertFromHalf(lodVar.value.u16v[0]); else if(lodVar.type == VarType::Double) - uniformParams.lod = (float)lodVar.value.dv[0]; + uniformParams.lod = (float)lodVar.value.f64v[0]; constParams.useGradOrGatherOffsets = VK_FALSE; } else if(operands.flags & rdcspv::ImageOperands::Grad) @@ -1063,8 +1063,8 @@ public: { for(int i = 0; i < gradCoords; i++) { - uniformParams.ddx[i] = ddx.value.fv[i]; - uniformParams.ddy[i] = ddy.value.fv[i]; + uniformParams.ddx[i] = ddx.value.f32v[i]; + uniformParams.ddy[i] = ddy.value.f32v[i]; } } else if(ddx.type == VarType::Half) @@ -1079,8 +1079,8 @@ public: { for(int i = 0; i < gradCoords; i++) { - uniformParams.ddx[i] = (float)ddx.value.dv[i]; - uniformParams.ddy[i] = (float)ddy.value.dv[i]; + uniformParams.ddx[i] = (float)ddx.value.f64v[i]; + uniformParams.ddy[i] = (float)ddy.value.f64v[i]; } } } @@ -1097,8 +1097,8 @@ public: { for(int i = 0; i < gradCoords; i++) { - uniformParams.ddx[i] = ddxCalc.value.fv[i]; - uniformParams.ddy[i] = ddyCalc.value.fv[i]; + uniformParams.ddx[i] = ddxCalc.value.f32v[i]; + uniformParams.ddy[i] = ddyCalc.value.f32v[i]; } } else if(ddxCalc.type == VarType::Half) @@ -1113,8 +1113,8 @@ public: { for(int i = 0; i < gradCoords; i++) { - uniformParams.ddx[i] = (float)ddxCalc.value.dv[i]; - uniformParams.ddy[i] = (float)ddyCalc.value.dv[i]; + uniformParams.ddx[i] = (float)ddxCalc.value.f64v[i]; + uniformParams.ddy[i] = (float)ddyCalc.value.f64v[i]; } } } @@ -1127,16 +1127,16 @@ public: for(uint8_t c = 0; c < constOffset.columns; c++) { if(constOffset.type == VarType::SByte) - constOffset.value.iv[c] = constOffset.value.s8v[c]; + constOffset.value.s32v[c] = constOffset.value.s8v[c]; else if(constOffset.type == VarType::SShort) - constOffset.value.iv[c] = constOffset.value.s16v[c]; + constOffset.value.s32v[c] = constOffset.value.s16v[c]; } - uniformParams.offset.x = constOffset.value.i.x; + uniformParams.offset.x = constOffset.value.s32v[0]; if(gradCoords >= 2) - uniformParams.offset.y = constOffset.value.i.y; + uniformParams.offset.y = constOffset.value.s32v[1]; if(gradCoords >= 3) - uniformParams.offset.z = constOffset.value.i.z; + uniformParams.offset.z = constOffset.value.s32v[2]; } else if(operands.flags & rdcspv::ImageOperands::Offset) { @@ -1146,16 +1146,16 @@ public: for(uint8_t c = 0; c < offset.columns; c++) { if(offset.type == VarType::SByte) - offset.value.iv[c] = offset.value.s8v[c]; + offset.value.s32v[c] = offset.value.s8v[c]; else if(offset.type == VarType::SShort) - offset.value.iv[c] = offset.value.s16v[c]; + offset.value.s32v[c] = offset.value.s16v[c]; } - uniformParams.offset.x = offset.value.i.x; + uniformParams.offset.x = offset.value.s32v[0]; if(gradCoords >= 2) - uniformParams.offset.y = offset.value.i.y; + uniformParams.offset.y = offset.value.s32v[1]; if(gradCoords >= 3) - uniformParams.offset.z = offset.value.i.z; + uniformParams.offset.z = offset.value.s32v[2]; } break; @@ -1320,11 +1320,11 @@ public: else if(output.type == VarType::Double) { for(uint8_t c = 0; c < 4; c++) - output.value.dv[c] = ret[c]; + output.value.f64v[c] = ret[c]; } else { - memcpy(output.value.uv, ret, sizeof(Vec4f)); + memcpy(output.value.u32v.data(), ret, sizeof(Vec4f)); } m_DebugData.ReadbackBuffer.Unmap(); @@ -1395,7 +1395,7 @@ public: { RDCASSERTEQUAL(params[i].type, params[0].type); double p[4] = {}; - memcpy(p, params[i].value.fv, VarTypeByteSize(params[i].type) * params[i].columns); + memcpy(p, params[i].value.f32v.data(), VarTypeByteSize(params[i].type) * params[i].columns); ObjDisp(cmd)->CmdPushConstants(Unwrap(cmd), Unwrap(m_DebugData.PipeLayout), VK_SHADER_STAGE_ALL, uint32_t(sizeof(p) * i), sizeof(p), p); } @@ -1445,7 +1445,7 @@ public: if(op == rdcspv::GLSLstd450::Length || op == rdcspv::GLSLstd450::Distance) output.columns = 1; - memcpy(output.value.uv, ret, VarTypeByteSize(output.type) * output.columns); + memcpy(output.value.u32v.data(), ret, VarTypeByteSize(output.type) * output.columns); m_DebugData.ReadbackBuffer.Unmap(); @@ -3869,7 +3869,7 @@ ShaderDebugTrace *VulkanReplay::DebugVertex(uint32_t eventId, uint32_t vertid, u var.type = VarType::Float; RDCASSERTEQUAL(fmt.compByteWidth, VarTypeByteSize(var.type)); - memcpy(var.value.u64v, data.data(), fmt.compByteWidth * fmt.compCount); + memcpy(var.value.u8v.data(), data.data(), fmt.compByteWidth * fmt.compCount); } } else @@ -4531,11 +4531,11 @@ ShaderDebugTrace *VulkanReplay::DebugPixel(uint32_t eventId, uint32_t x, uint32_ const size_t sz = elemSize * param.compCount; - memcpy(((byte *)var.value.u64v) + elemSize * comp, value + i * paramAlign, sz); - memcpy(((byte *)deriv.ddxcoarse.value.u64v) + elemSize * comp, ddxcoarse + i * paramAlign, sz); - memcpy(((byte *)deriv.ddycoarse.value.u64v) + elemSize * comp, ddycoarse + i * paramAlign, sz); - memcpy(((byte *)deriv.ddxfine.value.u64v) + elemSize * comp, ddxfine + i * paramAlign, sz); - memcpy(((byte *)deriv.ddyfine.value.u64v) + elemSize * comp, ddyfine + i * paramAlign, sz); + memcpy((var.value.u8v.data()) + elemSize * comp, value + i * paramAlign, sz); + memcpy((deriv.ddxcoarse.value.u8v.data()) + elemSize * comp, ddxcoarse + i * paramAlign, sz); + memcpy((deriv.ddycoarse.value.u8v.data()) + elemSize * comp, ddycoarse + i * paramAlign, sz); + memcpy((deriv.ddxfine.value.u8v.data()) + elemSize * comp, ddxfine + i * paramAlign, sz); + memcpy((deriv.ddyfine.value.u8v.data()) + elemSize * comp, ddyfine + i * paramAlign, sz); } ret = debugger->BeginDebug(apiWrapper, ShaderStage::Pixel, entryPoint, spec, diff --git a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp index b20c2477b..8bd130e7b 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp @@ -4235,10 +4235,10 @@ bool WrappedVulkan::Serialise_vkCmdDebugMarkerBeginEXT(SerialiserType &ser, draw.name = Marker.pMarkerName ? Marker.pMarkerName : ""; draw.flags |= DrawFlags::PushMarker; - draw.markerColor[0] = RDCCLAMP(Marker.color[0], 0.0f, 1.0f); - draw.markerColor[1] = RDCCLAMP(Marker.color[1], 0.0f, 1.0f); - draw.markerColor[2] = RDCCLAMP(Marker.color[2], 0.0f, 1.0f); - draw.markerColor[3] = RDCCLAMP(Marker.color[3], 0.0f, 1.0f); + draw.markerColor.x = RDCCLAMP(Marker.color[0], 0.0f, 1.0f); + draw.markerColor.y = RDCCLAMP(Marker.color[1], 0.0f, 1.0f); + draw.markerColor.z = RDCCLAMP(Marker.color[2], 0.0f, 1.0f); + draw.markerColor.w = RDCCLAMP(Marker.color[3], 0.0f, 1.0f); AddEvent(); AddDrawcall(draw, false); @@ -4376,10 +4376,10 @@ bool WrappedVulkan::Serialise_vkCmdDebugMarkerInsertEXT(SerialiserType &ser, draw.name = Marker.pMarkerName ? Marker.pMarkerName : ""; draw.flags |= DrawFlags::SetMarker; - draw.markerColor[0] = RDCCLAMP(Marker.color[0], 0.0f, 1.0f); - draw.markerColor[1] = RDCCLAMP(Marker.color[1], 0.0f, 1.0f); - draw.markerColor[2] = RDCCLAMP(Marker.color[2], 0.0f, 1.0f); - draw.markerColor[3] = RDCCLAMP(Marker.color[3], 0.0f, 1.0f); + draw.markerColor.x = RDCCLAMP(Marker.color[0], 0.0f, 1.0f); + draw.markerColor.y = RDCCLAMP(Marker.color[1], 0.0f, 1.0f); + draw.markerColor.z = RDCCLAMP(Marker.color[2], 0.0f, 1.0f); + draw.markerColor.w = RDCCLAMP(Marker.color[3], 0.0f, 1.0f); AddEvent(); AddDrawcall(draw, false); @@ -5153,10 +5153,10 @@ bool WrappedVulkan::Serialise_vkCmdBeginDebugUtilsLabelEXT(SerialiserType &ser, draw.name = Label.pLabelName ? Label.pLabelName : ""; draw.flags |= DrawFlags::PushMarker; - draw.markerColor[0] = RDCCLAMP(Label.color[0], 0.0f, 1.0f); - draw.markerColor[1] = RDCCLAMP(Label.color[1], 0.0f, 1.0f); - draw.markerColor[2] = RDCCLAMP(Label.color[2], 0.0f, 1.0f); - draw.markerColor[3] = RDCCLAMP(Label.color[3], 0.0f, 1.0f); + draw.markerColor.x = RDCCLAMP(Label.color[0], 0.0f, 1.0f); + draw.markerColor.y = RDCCLAMP(Label.color[1], 0.0f, 1.0f); + draw.markerColor.z = RDCCLAMP(Label.color[2], 0.0f, 1.0f); + draw.markerColor.w = RDCCLAMP(Label.color[3], 0.0f, 1.0f); AddEvent(); AddDrawcall(draw, false); @@ -5294,10 +5294,10 @@ bool WrappedVulkan::Serialise_vkCmdInsertDebugUtilsLabelEXT(SerialiserType &ser, draw.name = Label.pLabelName ? Label.pLabelName : ""; draw.flags |= DrawFlags::SetMarker; - draw.markerColor[0] = RDCCLAMP(Label.color[0], 0.0f, 1.0f); - draw.markerColor[1] = RDCCLAMP(Label.color[1], 0.0f, 1.0f); - draw.markerColor[2] = RDCCLAMP(Label.color[2], 0.0f, 1.0f); - draw.markerColor[3] = RDCCLAMP(Label.color[3], 0.0f, 1.0f); + draw.markerColor.x = RDCCLAMP(Label.color[0], 0.0f, 1.0f); + draw.markerColor.y = RDCCLAMP(Label.color[1], 0.0f, 1.0f); + draw.markerColor.z = RDCCLAMP(Label.color[2], 0.0f, 1.0f); + draw.markerColor.w = RDCCLAMP(Label.color[3], 0.0f, 1.0f); AddEvent(); AddDrawcall(draw, false); diff --git a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp index a3821fd30..dcbe8eea9 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp @@ -1579,10 +1579,10 @@ bool WrappedVulkan::Serialise_vkQueueBeginDebugUtilsLabelEXT(SerialiserType &ser draw.name = Label.pLabelName ? Label.pLabelName : ""; draw.flags |= DrawFlags::PushMarker; - draw.markerColor[0] = RDCCLAMP(Label.color[0], 0.0f, 1.0f); - draw.markerColor[1] = RDCCLAMP(Label.color[1], 0.0f, 1.0f); - draw.markerColor[2] = RDCCLAMP(Label.color[2], 0.0f, 1.0f); - draw.markerColor[3] = RDCCLAMP(Label.color[3], 0.0f, 1.0f); + draw.markerColor.x = RDCCLAMP(Label.color[0], 0.0f, 1.0f); + draw.markerColor.y = RDCCLAMP(Label.color[1], 0.0f, 1.0f); + draw.markerColor.z = RDCCLAMP(Label.color[2], 0.0f, 1.0f); + draw.markerColor.w = RDCCLAMP(Label.color[3], 0.0f, 1.0f); AddEvent(); m_RootEventID++; @@ -1681,10 +1681,10 @@ bool WrappedVulkan::Serialise_vkQueueInsertDebugUtilsLabelEXT(SerialiserType &se draw.name = Label.pLabelName ? Label.pLabelName : ""; draw.flags |= DrawFlags::SetMarker; - draw.markerColor[0] = RDCCLAMP(Label.color[0], 0.0f, 1.0f); - draw.markerColor[1] = RDCCLAMP(Label.color[1], 0.0f, 1.0f); - draw.markerColor[2] = RDCCLAMP(Label.color[2], 0.0f, 1.0f); - draw.markerColor[3] = RDCCLAMP(Label.color[3], 0.0f, 1.0f); + draw.markerColor.x = RDCCLAMP(Label.color[0], 0.0f, 1.0f); + draw.markerColor.y = RDCCLAMP(Label.color[1], 0.0f, 1.0f); + draw.markerColor.z = RDCCLAMP(Label.color[2], 0.0f, 1.0f); + draw.markerColor.w = RDCCLAMP(Label.color[3], 0.0f, 1.0f); AddEvent(); AddDrawcall(draw, false); diff --git a/renderdoc/replay/basic_types_tests.cpp b/renderdoc/replay/basic_types_tests.cpp index 5fa09e153..13cbc2dcb 100644 --- a/renderdoc/replay/basic_types_tests.cpp +++ b/renderdoc/replay/basic_types_tests.cpp @@ -30,6 +30,7 @@ #include "api/replay/rdcflatmap.h" #include "api/replay/rdcpair.h" #include "api/replay/rdcstr.h" +#include "api/replay/resourceid.h" #include "common/formatting.h" #include "common/globalconfig.h" #include "common/timing.h" @@ -1890,4 +1891,79 @@ TEST_CASE("Test flatmap type", "[basictypes][flatmap]") }; }; +union foo +{ + rdcfixedarray f32v; + rdcfixedarray u32v; + rdcfixedarray s32v; +}; + +TEST_CASE("Test rdcfixedarray type", "[basictypes][rdcfixedarray]") +{ + SECTION("Basic test") + { + rdcfixedarray test = {}; + + CHECK(test.size() == 8); + CHECK(test.byteSize() == 32); + CHECK(test.begin() + 8 == test.end()); + CHECK(test[0] == 0); + CHECK(test[2] == 0); + + test = {4, 1, 77, 0, 0, 8, 20, 934}; + + CHECK(test.contains(1)); + CHECK(!test.contains(2)); + CHECK(test.indexOf(8) == 5); + CHECK(test.indexOf(9) == -1); + + CHECK(test[0] == 4); + CHECK(test[2] == 77); + CHECK(test[4] == 0); + + int sum = 0; + for(int x : test) + sum += x; + + CHECK(sum == 1044); + + test[4] = 1; + + CHECK(test[0] == 4); + CHECK(test[2] == 77); + CHECK(test[4] == 1); + + sum = 0; + for(int x : test) + sum += x; + + CHECK(sum == 1045); + }; + + SECTION("Test of rdcfixedarray of ResourceId") + { + rdcfixedarray resources = {}; + + ResourceId r = ResourceIDGen::GetNewUniqueID(); + resources[2] = r; + resources[4] = ResourceIDGen::GetNewUniqueID(); + + CHECK(resources[2] != resources[4]); + CHECK(resources[2] == r); + }; + + SECTION("Test of rdcfixedarray in unions") + { + foo u = {}; + + u.f32v[0] = 1.0f; + + CHECK(u.u32v[0] == 0x3f800000); + + u = foo(); + + CHECK(u.u32v[0] == 0); + }; +}; + #endif // ENABLED(ENABLE_UNIT_TESTS) diff --git a/renderdoc/replay/replay_controller.cpp b/renderdoc/replay/replay_controller.cpp index 71d91b8cb..ef3727284 100644 --- a/renderdoc/replay/replay_controller.cpp +++ b/renderdoc/replay/replay_controller.cpp @@ -373,7 +373,7 @@ void ReplayController::AddFakeMarkers() mark.drawcallId = draws[start].drawcallId; mark.flags = DrawFlags::PushMarker; - memcpy(mark.outputs, draws[end].outputs, sizeof(mark.outputs)); + mark.outputs = draws[end].outputs; mark.depthOut = draws[end].depthOut; mark.name = "Guessed Pass"; @@ -1559,7 +1559,7 @@ PixelValue ReplayController::PickPixel(ResourceId tex, uint32_t x, uint32_t y, if(tex == ResourceId()) return ret; - m_pDevice->PickPixel(m_pDevice->GetLiveID(tex), x, y, sub, typeCast, ret.floatValue); + m_pDevice->PickPixel(m_pDevice->GetLiveID(tex), x, y, sub, typeCast, ret.floatValue.data()); return ret; } diff --git a/renderdoc/replay/replay_driver.cpp b/renderdoc/replay/replay_driver.cpp index d175d3673..ffc851a6b 100644 --- a/renderdoc/replay/replay_driver.cpp +++ b/renderdoc/replay/replay_driver.cpp @@ -369,7 +369,7 @@ void StandardFillCBufferVariable(ResourceId shader, const ShaderConstantDescript const byte *srcData = data.data() + dataOffset; const size_t avail = data.size() - dataOffset; - byte *dstData = elemByteSize == 8 ? (byte *)outvar.value.u64v : (byte *)outvar.value.uv; + byte *dstData = outvar.value.u8v.data(); const size_t dstStride = elemByteSize == 8 ? 8 : 4; // each secondaryDim element (row or column) is stored in a primaryDim-vector. @@ -401,7 +401,7 @@ void StandardFillCBufferVariable(ResourceId shader, const ShaderConstantDescript { for(size_t ri = 0; ri < rows; ri++) for(size_t ci = 0; ci < cols; ci++) - outvar.value.uv[ri * cols + ci] = tmp.value.uv[ci * rows + ri]; + outvar.value.u32v[ri * cols + ci] = tmp.value.u32v[ci * rows + ri]; } } @@ -412,8 +412,8 @@ void StandardFillCBufferVariable(ResourceId shader, const ShaderConstantDescript { for(size_t ci = 0; ci < cols; ci++) { - outvar.value.fv[ri * cols + ci] = - ConvertFromHalf((uint16_t)outvar.value.uv[ri * cols + ci]); + outvar.value.f32v[ri * cols + ci] = + ConvertFromHalf((uint16_t)outvar.value.u32v[ri * cols + ci]); } } } @@ -426,7 +426,7 @@ void StandardFillCBufferVariable(ResourceId shader, const ShaderConstantDescript { for(size_t ci = 0; ci < cols; ci++) { - uint32_t &u = outvar.value.uv[ri * cols + ci]; + uint32_t &u = outvar.value.u32v[ri * cols + ci]; if(u & testMask) u |= extendMask; diff --git a/renderdoc/serialise/serialiser.h b/renderdoc/serialise/serialiser.h index 5c9af0c17..03f405d82 100644 --- a/renderdoc/serialise/serialiser.h +++ b/renderdoc/serialise/serialiser.h @@ -765,6 +765,94 @@ public: return *this; } + template + Serialiser &Serialise(const rdcliteral &name, rdcfixedarray &el, + SerialiserFlags flags = SerialiserFlags::NoFlags) + { + // for consistency with other arrays, even though this is redundant, we serialise out and in the + // size + uint64_t count = N; + { + m_InternalElement++; + DoSerialise(*this, count); + m_InternalElement--; + + if(count != N) + RDCWARN("Fixed-size array length %zu serialised with different size %llu", N, count); + } + + if(ExportStructure()) + { + if(m_StructureStack.empty()) + { + RDCERR("Serialising object outside of chunk context! Start Chunk before any Serialise!"); + return *this; + } + + SDObject &parent = *m_StructureStack.back(); + + SDObject &arr = *parent.AddAndOwnChild(new SDObject(name, TypeName())); + m_StructureStack.push_back(&arr); + + arr.type.basetype = SDBasic::Array; + arr.type.byteSize = N; + arr.type.flags |= SDTypeFlags::FixedArray; + + arr.ReserveChildren(N); + + for(size_t i = 0; i < N; i++) + { + SDObject &obj = *arr.AddAndOwnChild(new SDObject("$el"_lit, TypeName())); + m_StructureStack.push_back(&obj); + + // default to struct. This will be overwritten if appropriate + obj.type.basetype = SDBasic::Struct; + obj.type.byteSize = sizeof(U); + if(std::is_union::value) + obj.type.flags |= SDTypeFlags::Union; + + // Check against the serialised count here - on read if we don't have the right size this + // means we won't read past the provided data. + if(i < count) + { + SerialiseDispatch::Do(*this, el[i]); + } + else + { + // we should have data for these elements, but we don't. Just default initialise + el[i] = U(); + } + + m_StructureStack.pop_back(); + } + + // if we have more data than the fixed sized array allows, we must simply discard the excess + if(count > N) + { + // prevent any trashing of structured data by these + m_InternalElement++; + U dummy; + SerialiseDispatch::Do(*this, dummy); + m_InternalElement--; + } + + m_StructureStack.pop_back(); + } + else + { + for(size_t i = 0; i < N && i < count; i++) + SerialiseDispatch::Do(*this, el[i]); + + for(size_t i = N; i < count; i++) + { + U dummy = U(); + SerialiseDispatch::Do(*this, dummy); + } + } + + return *this; + } + template Serialiser &Serialise(const rdcliteral &name, rdcpair &el, SerialiserFlags flags = SerialiserFlags::NoFlags) diff --git a/util/test/rdtest/shared/Buffer_Truncation.py b/util/test/rdtest/shared/Buffer_Truncation.py index 85d2e6f33..290b1df02 100644 --- a/util/test/rdtest/shared/Buffer_Truncation.py +++ b/util/test/rdtest/shared/Buffer_Truncation.py @@ -117,8 +117,8 @@ class Buffer_Truncation(rdtest.TestCase): outcol: rd.ShaderVariable = variables[1] self.check(outcol.name == "outcol") - if not rdtest.value_compare(outcol.value.fv[0:4], [0.0, 0.0, 0.0, 0.0]): - raise rdtest.TestFailureException("expected outcol to be 0s, but got {}".format(outcol.value.fv[0:4])) + if not rdtest.value_compare(outcol.value.f32v[0:4], [0.0, 0.0, 0.0, 0.0]): + raise rdtest.TestFailureException("expected outcol to be 0s, but got {}".format(outcol.value.f32v[0:4])) if self.controller.GetAPIProperties().shaderDebugging and pipe.GetShaderReflection( rd.ShaderStage.Pixel).debugInfo.debuggable: @@ -143,8 +143,8 @@ class Buffer_Truncation(rdtest.TestCase): self.check(debugged_cb.members[0].name == 'padding') self.check(debugged_cb.members[1].name == 'outcol') - if not rdtest.value_compare(debugged_cb.members[1].value.fv[0:4], [0.0, 0.0, 0.0, 0.0]): - raise rdtest.TestFailureException("expected outcol to be 0s, but got {}".format(debugged_cb.members[1].value.fv[0:4])) + if not rdtest.value_compare(debugged_cb.members[1].value.f32v[0:4], [0.0, 0.0, 0.0, 0.0]): + raise rdtest.TestFailureException("expected outcol to be 0s, but got {}".format(debugged_cb.members[1].value.f32v[0:4])) # D3D style, one source var for each member mapping to a register elif len(cbuf_sourceVars) == 17: debugged_cb = trace.constantBlocks[0].members[16] @@ -154,8 +154,8 @@ class Buffer_Truncation(rdtest.TestCase): self.check(cbuf_sourceVars[16].variables[0].name == 'cb0[16]') - if not rdtest.value_compare(debugged_cb.value.fv[0:4], [0.0, 0.0, 0.0, 0.0]): - raise rdtest.TestFailureException("expected outcol to be 0s, but got {}".format(debugged_cb.members[1].value.fv[0:4])) + if not rdtest.value_compare(debugged_cb.value.f32v[0:4], [0.0, 0.0, 0.0, 0.0]): + raise rdtest.TestFailureException("expected outcol to be 0s, but got {}".format(debugged_cb.members[1].value.f32v[0:4])) else: raise rdtest.TestFailureException("Unexpected number of constant buffer source vars {}".format(len(cbuf_sourceVars))) diff --git a/util/test/rdtest/shared/Draw_Zoo.py b/util/test/rdtest/shared/Draw_Zoo.py index a6c717fa9..daaa07ffc 100644 --- a/util/test/rdtest/shared/Draw_Zoo.py +++ b/util/test/rdtest/shared/Draw_Zoo.py @@ -163,7 +163,7 @@ class Draw_Zoo(rdtest.TestCase): "Output {} at vert {} (idx {}) instance {} has different size ({} values) to expectation ({} values)" .format(name, vtx, idx, inst, value.columns, len(expect))) - debugged = value.value.fv[0:value.columns] + debugged = value.value.f32v[0:value.columns] if not rdtest.value_compare(expect, debugged): raise rdtest.TestFailureException( diff --git a/util/test/rdtest/testcase.py b/util/test/rdtest/testcase.py index 6c570f900..508897acc 100644 --- a/util/test/rdtest/testcase.py +++ b/util/test/rdtest/testcase.py @@ -42,27 +42,27 @@ class ShaderVariableCheck: def value(self, value_: list): count = len(value_) if isinstance(value_[0], float): - if self.var.value.fv[0:count] != value_: + if list(self.var.value.f32v[0:count]) != list(value_): raise TestFailureException("Float variable {} value mismatch, expected {} but got {}" - .format(self.var.name, value_, self.var.value.fv[0:count])) + .format(self.var.name, value_, self.var.value.f32v[0:count])) else: # hack - check signed and unsigned values - if self.var.value.iv[0:count] != value_ and self.var.value.uv[0:count] != value_: + if list(self.var.value.s32v[0:count] ) != list(value_) and list(self.var.value.u32v[0:count]) != list(value_): raise TestFailureException("Int variable {} value mismatch, expected {} but got {} / {}" - .format(self.var.name, value_, self.var.value.iv[0:count], - self.var.value.uv[0:count])) + .format(self.var.name, value_, self.var.value.s32v[0:count], + self.var.value.u32v[0:count])) return self def longvalue(self, value_: list): count = len(value_) if isinstance(value_[0], float): - if self.var.value.dv[0:count] != value_: + if list(self.var.value.f64v[0:count]) != list(value_): raise TestFailureException("Float variable {} value mismatch, expected {} but got {}" - .format(self.var.name, value_, self.var.value.dv[0:count])) + .format(self.var.name, value_, self.var.value.f64v[0:count])) else: # hack - check signed and unsigned values - if self.var.value.s64v[0:count] != value_ and self.var.value.u64v[0:count] != value_: + if list(self.var.value.s64v[0:count]) != list(value_) and list(self.var.value.u64v[0:count]) != list(value_): raise TestFailureException("Int variable {} value mismatch, expected {} but got {} / {}" .format(self.var.name, value_, self.var.value.s64v[0:count], self.var.value.u64v[0:count])) @@ -619,12 +619,12 @@ class TestCase: debugged.type = sourceVar.type debugged.rows = sourceVar.rows debugged.columns = sourceVar.columns - fv = [0.0] * 16 + f32v = [0.0] * 16 for i, debugVarPath in enumerate(sourceVar.variables): debugVar = self.get_debug_var(debugVars, debugVarPath.name) debugged.rowMajor = debugVar.rowMajor - fv[i] = debugVar.value.fv[debugVarPath.component] - debugged.value.fv = fv + f32v[i] = debugVar.value.f32v[debugVarPath.component] + debugged.value.f32v = f32v return debugged def combine_source_vars(self, vars): diff --git a/util/test/tests/D3D11/D3D11_CBuffer_Zoo.py b/util/test/tests/D3D11/D3D11_CBuffer_Zoo.py index ffb609d8e..92932cc39 100644 --- a/util/test/tests/D3D11/D3D11_CBuffer_Zoo.py +++ b/util/test/tests/D3D11/D3D11_CBuffer_Zoo.py @@ -68,10 +68,10 @@ class D3D11_CBuffer_Zoo(rdtest.TestCase): debugged = self.evaluate_source_var(output, variables) - if not rdtest.util.value_compare(debugged.value.fv[0:4], [536.1, 537.0, 538.0, 539.0]): + if not rdtest.util.value_compare(debugged.value.f32v[0:4], [536.1, 537.0, 538.0, 539.0]): raise rdtest.TestFailureException( "Debugged output {} did not match expected {}".format( - debugged.value.fv[0:4], [536.1, 537.0, 538.0, 539.0])) + debugged.value.f32v[0:4], [536.1, 537.0, 538.0, 539.0])) rdtest.log.success("Debugged output matched as expected") diff --git a/util/test/tests/D3D11/D3D11_PrimitiveID.py b/util/test/tests/D3D11/D3D11_PrimitiveID.py index 3e86eebdc..457251779 100644 --- a/util/test/tests/D3D11/D3D11_PrimitiveID.py +++ b/util/test/tests/D3D11/D3D11_PrimitiveID.py @@ -27,9 +27,9 @@ class D3D11_PrimitiveID(rdtest.TestCase): # Look up the matching register in the inputs, and see if the expected value matches inputs: List[rd.ShaderVariable] = list(trace.inputs) primValue = [var for var in inputs if var.name == primInput.variables[0].name][0] - if primValue.value.uv[0] not in expected_prim: + if primValue.value.u32v[0] not in expected_prim: rdtest.log.error("Expected prim {} at {},{} did not match actual prim {}.".format( - str(expected_prim), x, y, primValue.value.uv[0])) + str(expected_prim), x, y, primValue.value.u32v[0])) return False # Compare shader debug output against an expected value instead of the RT's output, @@ -37,9 +37,9 @@ class D3D11_PrimitiveID(rdtest.TestCase): if expected_output is not None: output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0) debugged = self.evaluate_source_var(output, variables) - if debugged.value.fv[0:4] != expected_output: + if list(debugged.value.f32v[0:4]) != expected_output: rdtest.log.error("Expected value {} at {},{} did not match actual {}.".format( - expected_output, x, y, debugged.value.fv[0:4])) + expected_output, x, y, debugged.value.f32v[0:4])) return False self.controller.FreeTrace(trace) diff --git a/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py b/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py index ce040a724..4221ee58e 100644 --- a/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py +++ b/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py @@ -30,7 +30,7 @@ class D3D11_Shader_Debug_Zoo(rdtest.TestCase): debugged = self.evaluate_source_var(output, variables) try: - self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4 * test, 0, debugged.value.fv[0:4]) + self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4 * test, 0, debugged.value.f32v[0:4]) except rdtest.TestFailureException as ex: failed = True rdtest.log.error("Test {} did not match. {}".format(test, str(ex))) @@ -53,7 +53,7 @@ class D3D11_Shader_Debug_Zoo(rdtest.TestCase): # Validate that the correct sample index was debugged sampRegister = self.find_input_source_var(trace, rd.ShaderBuiltin.MSAASampleIndex) sampInput = [var for var in trace.inputs if var.name == sampRegister.variables[0].name][0] - if sampInput.value.uv[0] != test: + if sampInput.value.u32v[0] != test: rdtest.log.error("Test {} did not pick the correct sample.".format(test)) cycles, variables = self.process_trace(trace) @@ -64,7 +64,7 @@ class D3D11_Shader_Debug_Zoo(rdtest.TestCase): # Validate the debug output result try: - self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4, 4, debugged.value.fv[0:4], sub=rd.Subresource(0, 0, test)) + self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4, 4, debugged.value.f32v[0:4], sub=rd.Subresource(0, 0, test)) except rdtest.TestFailureException as ex: failed = True rdtest.log.error("Test {} did not match. {}".format(test, str(ex))) diff --git a/util/test/tests/D3D11/D3D11_Shader_Linkage_Zoo.py b/util/test/tests/D3D11/D3D11_Shader_Linkage_Zoo.py index 520816878..1058044e7 100644 --- a/util/test/tests/D3D11/D3D11_Shader_Linkage_Zoo.py +++ b/util/test/tests/D3D11/D3D11_Shader_Linkage_Zoo.py @@ -33,7 +33,7 @@ class D3D11_Shader_Linkage_Zoo(rdtest.TestCase): debugged = self.evaluate_source_var(output, variables) try: - self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 200, 150, debugged.value.fv[0:4]) + self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 200, 150, debugged.value.f32v[0:4]) except rdtest.TestFailureException as ex: failed = True rdtest.log.error("Test {} did not match. {}".format(event_name, str(ex))) diff --git a/util/test/tests/D3D12/D3D12_CBuffer_Zoo.py b/util/test/tests/D3D12/D3D12_CBuffer_Zoo.py index 332bbc904..13286e089 100644 --- a/util/test/tests/D3D12/D3D12_CBuffer_Zoo.py +++ b/util/test/tests/D3D12/D3D12_CBuffer_Zoo.py @@ -144,10 +144,10 @@ class D3D12_CBuffer_Zoo(rdtest.TestCase): debugged = self.evaluate_source_var(output, variables) - if not rdtest.util.value_compare(debugged.value.fv[0:4], [536.1, 537.0, 538.0, 539.0]): + if not rdtest.util.value_compare(debugged.value.f32v[0:4], [536.1, 537.0, 538.0, 539.0]): raise rdtest.TestFailureException( "Debugged output {} did not match expected {}".format( - debugged.value.fv[0:4], [536.1, 537.0, 538.0, 539.0])) + debugged.value.f32v[0:4], [536.1, 537.0, 538.0, 539.0])) rdtest.log.success("Debugged output matched as expected") diff --git a/util/test/tests/D3D12/D3D12_PrimitiveID.py b/util/test/tests/D3D12/D3D12_PrimitiveID.py index 86bbdb074..11bc81667 100644 --- a/util/test/tests/D3D12/D3D12_PrimitiveID.py +++ b/util/test/tests/D3D12/D3D12_PrimitiveID.py @@ -30,9 +30,9 @@ class D3D12_PrimitiveID(rdtest.TestCase): # Look up the matching register in the inputs, and see if the expected value matches inputs: List[rd.ShaderVariable] = list(trace.inputs) primValue = [var for var in inputs if var.name == primInput.variables[0].name][0] - if primValue.value.uv[0] not in expected_prim: + if primValue.value.u32v[0] not in expected_prim: rdtest.log.error("Expected prim {} at {},{} did not match actual prim {}.".format( - str(expected_prim), x, y, primValue.value.uv[0])) + str(expected_prim), x, y, primValue.value.u32v[0])) return False # Compare shader debug output against an expected value instead of the RT's output, @@ -40,9 +40,9 @@ class D3D12_PrimitiveID(rdtest.TestCase): if expected_output is not None: output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0) debugged = self.evaluate_source_var(output, variables) - if debugged.value.fv[0:4] != expected_output: + if list(debugged.value.f32v[0:4]) != expected_output: rdtest.log.error("Expected value {} at {},{} did not match actual {}.".format( - expected_output, x, y, debugged.value.fv[0:4])) + expected_output, x, y, debugged.value.f32v[0:4])) return False self.controller.FreeTrace(trace) diff --git a/util/test/tests/D3D12/D3D12_Resource_Mapping_Zoo.py b/util/test/tests/D3D12/D3D12_Resource_Mapping_Zoo.py index edf174e38..92c969d27 100644 --- a/util/test/tests/D3D12/D3D12_Resource_Mapping_Zoo.py +++ b/util/test/tests/D3D12/D3D12_Resource_Mapping_Zoo.py @@ -24,7 +24,7 @@ class D3D12_Resource_Mapping_Zoo(rdtest.TestCase): debugged = self.evaluate_source_var(output, variables) try: - self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, x, y, debugged.value.fv[0:4]) + self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, x, y, debugged.value.f32v[0:4]) except rdtest.TestFailureException as ex: rdtest.log.error("Test {} did not match. {}".format(test_name, str(ex))) return False diff --git a/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py b/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py index f34207a24..cfbcbe7b8 100644 --- a/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py +++ b/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py @@ -41,7 +41,7 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase): debugged = self.evaluate_source_var(output, variables) try: - self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4 * test, 0, debugged.value.fv[0:4]) + self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4 * test, 0, debugged.value.f32v[0:4]) except rdtest.TestFailureException as ex: failed = True rdtest.log.error("Test {} did not match. {}".format(test, str(ex))) @@ -66,7 +66,7 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase): # Validate that the correct sample index was debugged sampRegister = self.find_input_source_var(trace, rd.ShaderBuiltin.MSAASampleIndex) sampInput = [var for var in trace.inputs if var.name == sampRegister.variables[0].name][0] - if sampInput.value.uv[0] != test: + if sampInput.value.u32v[0] != test: rdtest.log.error("Test {} did not pick the correct sample.".format(test)) cycles, variables = self.process_trace(trace) @@ -77,7 +77,7 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase): # Validate the debug output result try: - self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4, 4, debugged.value.fv[0:4], sub=rd.Subresource(0, 0, test)) + self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4, 4, debugged.value.f32v[0:4], sub=rd.Subresource(0, 0, test)) except rdtest.TestFailureException as ex: failed = True rdtest.log.error("Test {} did not match. {}".format(test, str(ex))) @@ -99,10 +99,10 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase): debugged = self.evaluate_source_var(output, variables) - if not rdtest.value_compare(debugged.value.fv[0:4], [0.3, 0.5, 0.8, 1.0]): + if not rdtest.value_compare(debugged.value.f32v[0:4], [0.3, 0.5, 0.8, 1.0]): failed = True rdtest.log.error( - "Vertex shader color output did not match expectation ({}). {}".format(str(debugged.value.fv[0:4]), + "Vertex shader color output did not match expectation ({}). {}".format(str(debugged.value.f32v[0:4]), str(ex))) rdtest.log.success("VertexSample VS was debugged correctly") @@ -118,7 +118,7 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase): # Validate the debug output result try: - self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 51, 51, debugged.value.fv[0:4]) + self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 51, 51, debugged.value.f32v[0:4]) except rdtest.TestFailureException as ex: failed = True rdtest.log.error("Vertex sample pixel shader output did not match. {}".format(str(ex))) diff --git a/util/test/tests/D3D12/D3D12_Shader_Linkage_Zoo.py b/util/test/tests/D3D12/D3D12_Shader_Linkage_Zoo.py index 6a8427da5..81f8c119b 100644 --- a/util/test/tests/D3D12/D3D12_Shader_Linkage_Zoo.py +++ b/util/test/tests/D3D12/D3D12_Shader_Linkage_Zoo.py @@ -41,7 +41,7 @@ class D3D12_Shader_Linkage_Zoo(rdtest.TestCase): debugged = self.evaluate_source_var(output, variables) try: - self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 200, 150, debugged.value.fv[0:4]) + self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 200, 150, debugged.value.f32v[0:4]) except rdtest.TestFailureException as ex: failed = True rdtest.log.error("Test {} did not match. {}".format(event_name, str(ex))) diff --git a/util/test/tests/Iter_Test.py b/util/test/tests/Iter_Test.py index 5819ec02a..c7f8cd976 100644 --- a/util/test/tests/Iter_Test.py +++ b/util/test/tests/Iter_Test.py @@ -134,15 +134,15 @@ class Iter_Test(rdtest.TestCase): compType = rd.VarTypeCompType(value.type) if compType == rd.CompType.UInt: - debugged = value.value.uv[0:value.columns] + debugged = value.value.u32v[0:value.columns] elif compType == rd.CompType.SInt: - debugged = value.value.iv[0:value.columns] + debugged = value.value.s32v[0:value.columns] else: - debugged = value.value.fv[0:value.columns] + debugged = value.value.f32v[0:value.columns] # For now, ignore debugged values that are uninitialised. This is an application bug but it causes false reports of problems for comp in range(4): - if value.value.uv[comp] == 0xcccccccc: + if value.value.u32v[comp] == 0xcccccccc: debugged[comp] = expect[comp] # Unfortunately we can't ever trust that we should get back a matching results, because some shaders @@ -275,7 +275,7 @@ class Iter_Test(rdtest.TestCase): # For now, ignore debugged values that are uninitialised. This is an application bug but it causes false reports of problems for idx in range(4): - if debugged.value.uv[idx] == 0xcccccccc: + if debugged.value.u32v[idx] == 0xcccccccc: debuggedValue[idx] = lastmod.shaderOut.col.floatValue[idx] # Unfortunately we can't ever trust that we should get back a matching results, because some shaders diff --git a/util/test/tests/Vulkan/VK_Indirect.py b/util/test/tests/Vulkan/VK_Indirect.py index 18899514b..eff37f836 100644 --- a/util/test/tests/Vulkan/VK_Indirect.py +++ b/util/test/tests/Vulkan/VK_Indirect.py @@ -146,9 +146,9 @@ class VK_Indirect(rdtest.TestCase): self.check(dispatches and len(dispatches.children) == 3) - self.check(dispatches.children[0].dispatchDimension == [0,0,0]) - self.check(dispatches.children[1].dispatchDimension == [1,1,1]) - self.check(dispatches.children[2].dispatchDimension == [3,4,5]) + self.check(dispatches.children[0].dispatchDimension == (0, 0, 0)) + self.check(dispatches.children[1].dispatchDimension == (1, 1, 1)) + self.check(dispatches.children[2].dispatchDimension == (3, 4, 5)) rdtest.log.success("{} Indirect dispatches are the correct dimensions".format(level)) diff --git a/util/test/tests/Vulkan/VK_Shader_Debug_Zoo.py b/util/test/tests/Vulkan/VK_Shader_Debug_Zoo.py index d4d411ed2..ad4a64a68 100644 --- a/util/test/tests/Vulkan/VK_Shader_Debug_Zoo.py +++ b/util/test/tests/Vulkan/VK_Shader_Debug_Zoo.py @@ -46,7 +46,7 @@ class VK_Shader_Debug_Zoo(rdtest.TestCase): debugged = self.evaluate_source_var(output, variables) try: - self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, x, y, debugged.value.fv[0:4]) + self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, x, y, debugged.value.f32v[0:4]) except rdtest.TestFailureException as ex: failed = True rdtest.log.error("Test {} in sub-section {} did not match. {}".format(test, child, str(ex))) diff --git a/util/test/tests/Vulkan/VK_Spec_Constants.py b/util/test/tests/Vulkan/VK_Spec_Constants.py index 90dc45c44..ffbb8c3af 100644 --- a/util/test/tests/Vulkan/VK_Spec_Constants.py +++ b/util/test/tests/Vulkan/VK_Spec_Constants.py @@ -47,7 +47,7 @@ class VK_Spec_Constants(rdtest.TestCase): expected = [0.0, 0.0, 0.0, 0.0] expected[col] = 1.0 - val = [i for i in cb_vars[0].members[col].value.fv[0:4]] + val = [i for i in cb_vars[0].members[col].value.f32v[0:4]] if not rdtest.value_compare(val, expected): raise rdtest.TestFailureException("Cbuffer[{}] value {} doesn't match expectation {}".format(col, val, expected)) @@ -63,8 +63,8 @@ class VK_Spec_Constants(rdtest.TestCase): self.check(len(cb_vars) == 1) - if not rdtest.value_compare(cb_vars[0].value.i.x, num_colors): - raise rdtest.TestFailureException("Spec constant is {}, not {}".format(cb_vars[0].value.i.x, num_colors)) + if not rdtest.value_compare(cb_vars[0].value.s32v[0], num_colors): + raise rdtest.TestFailureException("Spec constant is {}, not {}".format(cb_vars[0].value.s32v[0], num_colors)) rdtest.log.success("Draw with {} colors specialisation constant is as expected".format(num_colors))