diff --git a/qrenderdoc/Code/FormatElement.cpp b/qrenderdoc/Code/FormatElement.cpp index 3a0c9bb7f..3deb57787 100644 --- a/qrenderdoc/Code/FormatElement.cpp +++ b/qrenderdoc/Code/FormatElement.cpp @@ -551,7 +551,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons ret.push_back((float)((packed >> 10) & 0x1f) / 31.0f); ret.push_back(((packed & 0x8000) > 0) ? 1.0f : 0.0f); - if(format.bgraOrder) + if(format.bgraOrder()) { QVariant tmp = ret[2]; ret[2] = ret[0]; @@ -566,7 +566,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons ret.push_back((float)((packed >> 5) & 0x3f) / 63.0f); ret.push_back((float)((packed >> 11) & 0x1f) / 31.0f); - if(format.bgraOrder) + if(format.bgraOrder()) { QVariant tmp = ret[2]; ret[2] = ret[0]; @@ -582,7 +582,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons ret.push_back((float)((packed >> 8) & 0xf) / 15.0f); ret.push_back((float)((packed >> 12) & 0xf) / 15.0f); - if(format.bgraOrder) + if(format.bgraOrder()) { QVariant tmp = ret[2]; ret[2] = ret[0]; @@ -601,7 +601,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons uint32_t b = (packed >> 20) & 0x3ff; uint32_t a = (packed >> 30) & 0x003; - if(format.bgraOrder) + if(format.bgraOrder()) { uint32_t tmp = b; b = r; @@ -835,7 +835,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons } } - if(format.bgraOrder) + if(format.bgraOrder()) { QVariant tmp = ret[2]; ret[2] = ret[0]; diff --git a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp index 5e1b7690a..59643a497 100644 --- a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp @@ -1790,7 +1790,7 @@ void GLPipelineStateViewer::setState() format = tex->format.Name(); typeName = ToQStr(tex->type); - if(tex->format.srgbCorrected && !state.framebuffer.framebufferSRGB) + if(tex->format.srgbCorrected() && !state.framebuffer.framebufferSRGB) format += lit(" (GL_FRAMEBUFFER_SRGB = 0)"); } diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 257fcd74a..03a2c5522 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -839,7 +839,7 @@ void TextureViewer::UI_UpdateStatusText() float g = qBound(0.0f, m_CurHoverValue.floatValue[1], 1.0f); float b = qBound(0.0f, m_CurHoverValue.floatValue[2], 1.0f); - if(tex.format.srgbCorrected || (tex.creationFlags & TextureCategory::SwapBuffer)) + if(tex.format.srgbCorrected() || (tex.creationFlags & TextureCategory::SwapBuffer)) { r = powf(r, 1.0f / 2.2f); g = powf(g, 1.0f / 2.2f); @@ -1404,7 +1404,7 @@ void TextureViewer::UI_UpdateChannels() } else { - if(tex != NULL && !tex->format.srgbCorrected) + if(tex != NULL && !tex->format.srgbCorrected()) ENABLE(ui->gammaDisplay); else DISABLE(ui->gammaDisplay); @@ -1413,7 +1413,7 @@ void TextureViewer::UI_UpdateChannels() !ui->gammaDisplay->isEnabled() || ui->gammaDisplay->isChecked(); } - if(tex != NULL && tex->format.srgbCorrected) + if(tex != NULL && tex->format.srgbCorrected()) m_TexDisplay.linearDisplayAsGamma = false; bool dsv = false; diff --git a/renderdoc/api/replay/data_types.h b/renderdoc/api/replay/data_types.h index 5384dcb1d..6280ec13a 100644 --- a/renderdoc/api/replay/data_types.h +++ b/renderdoc/api/replay/data_types.h @@ -133,15 +133,14 @@ struct ResourceFormat compCount = compByteWidth = 0; compType = CompType::Typeless; - bgraOrder = false; - srgbCorrected = false; + flags = 0; } ResourceFormat(const ResourceFormat &) = default; bool operator==(const ResourceFormat &r) const { return type == r.type && compCount == r.compCount && compByteWidth == r.compByteWidth && - compType == r.compType && bgraOrder == r.bgraOrder && srgbCorrected == r.srgbCorrected; + compType == r.compType && flags == r.flags; } bool operator<(const ResourceFormat &r) const { @@ -153,10 +152,8 @@ struct ResourceFormat return compByteWidth < r.compByteWidth; if(compType != r.compType) return compType < r.compType; - if(bgraOrder != r.bgraOrder) - return bgraOrder < r.bgraOrder; - if(srgbCorrected != r.srgbCorrected) - return srgbCorrected < r.srgbCorrected; + if(flags != r.flags) + return flags < r.flags; return false; } @@ -172,12 +169,45 @@ struct ResourceFormat } DOCUMENT(R"(:return: ``True`` if the ``ResourceFormat`` is a 'special' non-regular type. -:type: ``bool`` +:rtype: ``bool`` )"); bool Special() const { return type != ResourceFormatType::Regular; } DOCUMENT(R"(The :class:`ResourceFormatType` of this format. If the value is not :attr:`ResourceFormatType.Regular` then it's a non-uniform layout like block-compressed. )"); + + DOCUMENT(R"(:return: ``True`` if the components are to be read in ``BGRA`` order. +:rtype: ``bool`` +)"); + bool bgraOrder() const { return (flags & ResourceFormat_BGRA) != 0; } + DOCUMENT(R"(:return: ``True`` if the components are SRGB corrected on read and write. +:rtype: ``bool`` +)"); + bool srgbCorrected() const { return (flags & ResourceFormat_SRGB) != 0; } + DOCUMENT(R"(Set BGRA order flag. See :meth:`bgraOrder`. + +:param bool flag: The new flag value. +)"); + void setBgraOrder(bool flag) + { + if(flag) + flags |= ResourceFormat_BGRA; + else + flags &= ~ResourceFormat_BGRA; + } + + DOCUMENT(R"(Set SRGB correction flag. See :meth:`srgbCorrected`. + +:param bool flag: The new flag value. +)"); + void setSrgbCorrected(bool flag) + { + if(flag) + flags |= ResourceFormat_SRGB; + else + flags &= ~ResourceFormat_SRGB; + } + ResourceFormatType type; DOCUMENT("The :class:`type ` of each component."); @@ -187,10 +217,17 @@ struct ResourceFormat DOCUMENT("The width in bytes of each component."); uint8_t compByteWidth; - DOCUMENT("``True`` if the components are to be read in ``BGRA`` order."); - bool bgraOrder; - DOCUMENT("``True`` if the components are SRGB corrected on read and write."); - bool srgbCorrected; +private: + enum + { + ResourceFormat_BGRA = 0x001, + ResourceFormat_SRGB = 0x002, + }; + uint16_t flags; + + // make DoSerialise a friend so it can serialise flags + template + friend void DoSerialise(SerialiserType &ser, ResourceFormat &el); }; DECLARE_REFLECTION_STRUCT(ResourceFormat); @@ -277,7 +314,10 @@ typically it is one parent to many derived. )"); rdcarray parentResources; - DOCUMENT("Utility function for setting up a custom name to overwrite the auto-generated one."); + DOCUMENT(R"(Utility function for setting up a custom name to overwrite the auto-generated one. + +:param str givenName: The custom name to use. +)"); inline void SetCustomName(const rdcstr &givenName) { autogeneratedName = false; diff --git a/renderdoc/api/replay/pipestate.inl b/renderdoc/api/replay/pipestate.inl index 507dd6a00..7377530db 100644 --- a/renderdoc/api/replay/pipestate.inl +++ b/renderdoc/api/replay/pipestate.inl @@ -821,7 +821,7 @@ rdcarray PipeState::GetVertexInputs() const ret[a].format.compCount = (uint8_t)compCount; ret[a].format.compType = compType; ret[a].format.type = ResourceFormatType::Regular; - ret[a].format.srgbCorrected = false; + ret[a].format.setSrgbCorrected(false); } } diff --git a/renderdoc/common/dds_readwrite.cpp b/renderdoc/common/dds_readwrite.cpp index ef756196b..b999d1f96 100644 --- a/renderdoc/common/dds_readwrite.cpp +++ b/renderdoc/common/dds_readwrite.cpp @@ -252,17 +252,17 @@ ResourceFormat DXGIFormat2ResourceFormat(DXGI_FORMAT format) case DXGI_FORMAT_BC1_UNORM: case DXGI_FORMAT_BC1_UNORM_SRGB: special.type = ResourceFormatType::BC1; - special.srgbCorrected = (format == DXGI_FORMAT_BC1_UNORM_SRGB ? true : false); + special.setSrgbCorrected(format == DXGI_FORMAT_BC1_UNORM_SRGB); return special; case DXGI_FORMAT_BC2_UNORM: case DXGI_FORMAT_BC2_UNORM_SRGB: special.type = ResourceFormatType::BC2; - special.srgbCorrected = (format == DXGI_FORMAT_BC2_UNORM_SRGB ? true : false); + special.setSrgbCorrected(format == DXGI_FORMAT_BC2_UNORM_SRGB); return special; case DXGI_FORMAT_BC3_UNORM: case DXGI_FORMAT_BC3_UNORM_SRGB: special.type = ResourceFormatType::BC3; - special.srgbCorrected = (format == DXGI_FORMAT_BC3_UNORM_SRGB ? true : false); + special.setSrgbCorrected(format == DXGI_FORMAT_BC3_UNORM_SRGB); return special; case DXGI_FORMAT_BC4_UNORM: case DXGI_FORMAT_BC4_SNORM: @@ -282,7 +282,7 @@ ResourceFormat DXGIFormat2ResourceFormat(DXGI_FORMAT format) case DXGI_FORMAT_BC7_UNORM: case DXGI_FORMAT_BC7_UNORM_SRGB: special.type = ResourceFormatType::BC7; - special.srgbCorrected = (format == DXGI_FORMAT_BC7_UNORM_SRGB ? true : false); + special.setSrgbCorrected(format == DXGI_FORMAT_BC7_UNORM_SRGB); return special; case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT: @@ -291,18 +291,18 @@ ResourceFormat DXGIFormat2ResourceFormat(DXGI_FORMAT format) return special; case DXGI_FORMAT_R11G11B10_FLOAT: special.type = ResourceFormatType::R11G11B10; return special; case DXGI_FORMAT_B5G6R5_UNORM: - fmt8.bgraOrder = true; + fmt8.setBgraOrder(true); special.type = ResourceFormatType::R5G6B5; return special; case DXGI_FORMAT_B5G5R5A1_UNORM: - fmt8.bgraOrder = true; + fmt8.setBgraOrder(true); special.type = ResourceFormatType::R5G5B5A1; return special; case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: special.type = ResourceFormatType::R9G9B9E5; return special; case DXGI_FORMAT_B4G4R4A4_UNORM: - fmt8.bgraOrder = true; + fmt8.setBgraOrder(true); special.type = ResourceFormatType::R4G4B4A4; return special; case DXGI_FORMAT_D24_UNORM_S8_UINT: special.type = ResourceFormatType::D24S8; return special; @@ -398,7 +398,7 @@ ResourceFormat DXGIFormat2ResourceFormat(DXGI_FORMAT format) return fmt8; case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: fmt8.compType = CompType::UNorm; - fmt8.srgbCorrected = true; + fmt8.setSrgbCorrected(true); fmt8.compCount = 4; return fmt8; case DXGI_FORMAT_R8G8B8A8_UNORM: fmt8.compCount = 4; return fmt8; @@ -406,8 +406,8 @@ ResourceFormat DXGIFormat2ResourceFormat(DXGI_FORMAT format) case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: fmt8.compType = CompType::UNorm; fmt8.compCount = 4; - fmt8.bgraOrder = true; - fmt8.srgbCorrected = (format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB ? true : false); + fmt8.setBgraOrder(true); + fmt8.setSrgbCorrected(format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB); return fmt8; case DXGI_FORMAT_R8G8_UINT: @@ -442,11 +442,11 @@ DXGI_FORMAT ResourceFormat2DXGIFormat(ResourceFormat format) switch(format.type) { case ResourceFormatType::BC1: - return format.srgbCorrected ? DXGI_FORMAT_BC1_UNORM_SRGB : DXGI_FORMAT_BC1_UNORM; + return format.srgbCorrected() ? DXGI_FORMAT_BC1_UNORM_SRGB : DXGI_FORMAT_BC1_UNORM; case ResourceFormatType::BC2: - return format.srgbCorrected ? DXGI_FORMAT_BC2_UNORM_SRGB : DXGI_FORMAT_BC2_UNORM; + return format.srgbCorrected() ? DXGI_FORMAT_BC2_UNORM_SRGB : DXGI_FORMAT_BC2_UNORM; case ResourceFormatType::BC3: - return format.srgbCorrected ? DXGI_FORMAT_BC3_UNORM_SRGB : DXGI_FORMAT_BC3_UNORM; + return format.srgbCorrected() ? DXGI_FORMAT_BC3_UNORM_SRGB : DXGI_FORMAT_BC3_UNORM; case ResourceFormatType::BC4: return format.compType == CompType::UNorm ? DXGI_FORMAT_BC4_UNORM : DXGI_FORMAT_BC4_SNORM; case ResourceFormatType::BC5: @@ -454,18 +454,20 @@ DXGI_FORMAT ResourceFormat2DXGIFormat(ResourceFormat format) case ResourceFormatType::BC6: return format.compType == CompType::UNorm ? DXGI_FORMAT_BC6H_UF16 : DXGI_FORMAT_BC6H_SF16; case ResourceFormatType::BC7: - return format.srgbCorrected ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM; + return format.srgbCorrected() ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM; case ResourceFormatType::R10G10B10A2: return format.compType == CompType::UNorm ? DXGI_FORMAT_R10G10B10A2_UNORM : DXGI_FORMAT_R10G10B10A2_UINT; case ResourceFormatType::R11G11B10: return DXGI_FORMAT_R11G11B10_FLOAT; - case ResourceFormatType::R5G6B5: RDCASSERT(format.bgraOrder); return DXGI_FORMAT_B5G6R5_UNORM; + case ResourceFormatType::R5G6B5: + RDCASSERT(format.bgraOrder()); + return DXGI_FORMAT_B5G6R5_UNORM; case ResourceFormatType::R5G5B5A1: - RDCASSERT(format.bgraOrder); + RDCASSERT(format.bgraOrder()); return DXGI_FORMAT_B5G5R5A1_UNORM; case ResourceFormatType::R9G9B9E5: return DXGI_FORMAT_R9G9B9E5_SHAREDEXP; case ResourceFormatType::R4G4B4A4: - RDCASSERT(format.bgraOrder); + RDCASSERT(format.bgraOrder()); return DXGI_FORMAT_B4G4R4A4_UNORM; case ResourceFormatType::D24S8: return DXGI_FORMAT_D24_UNORM_S8_UINT; case ResourceFormatType::D32S8: return DXGI_FORMAT_D32_FLOAT_S8X24_UINT; @@ -513,16 +515,16 @@ DXGI_FORMAT ResourceFormat2DXGIFormat(ResourceFormat format) case CompType::SNorm: return DXGI_FORMAT_R8G8B8A8_SNORM; default: case CompType::UNorm: - if(format.srgbCorrected) + if(format.srgbCorrected()) { - if(format.bgraOrder) + if(format.bgraOrder()) return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; else return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; } else { - if(format.bgraOrder) + if(format.bgraOrder()) return DXGI_FORMAT_B8G8R8A8_UNORM; else return DXGI_FORMAT_R8G8B8A8_UNORM; @@ -753,7 +755,7 @@ bool write_dds_to_file(FILE *f, const dds_data &data) header.ddspf.dwBBitMask = 0x00ff0000; header.ddspf.dwABitMask = 0xff000000; - if(data.format.bgraOrder) + if(data.format.bgraOrder()) std::swap(header.ddspf.dwRBitMask, header.ddspf.dwBBitMask); } else if(data.format.type == ResourceFormatType::BC1) @@ -971,7 +973,7 @@ dds_data load_dds_from_file(FILE *f) ret.format.type = ResourceFormatType::Regular; if(header.ddspf.dwBBitMask < header.ddspf.dwRBitMask) - ret.format.bgraOrder = true; + ret.format.setBgraOrder(true); } uint32_t bytesPerPixel = 1; diff --git a/renderdoc/core/image_viewer.cpp b/renderdoc/core/image_viewer.cpp index 76c43d67f..349e7030a 100644 --- a/renderdoc/core/image_viewer.cpp +++ b/renderdoc/core/image_viewer.cpp @@ -457,12 +457,12 @@ void ImageViewer::RefreshFile() rgba8_unorm.compCount = 4; rgba8_unorm.compType = CompType::UNorm; rgba8_unorm.type = ResourceFormatType::Regular; - rgba8_unorm.srgbCorrected = true; + rgba8_unorm.setSrgbCorrected(true); ResourceFormat rgba32_float = rgba8_unorm; rgba32_float.compByteWidth = 4; rgba32_float.compType = CompType::Float; - rgba32_float.srgbCorrected = false; + rgba32_float.setSrgbCorrected(false); texDetails.creationFlags = TextureCategory::SwapBuffer | TextureCategory::ColorTarget; texDetails.cubemap = false; diff --git a/renderdoc/core/replay_proxy.cpp b/renderdoc/core/replay_proxy.cpp index 80dd9ccbf..1e72e3ba8 100644 --- a/renderdoc/core/replay_proxy.cpp +++ b/renderdoc/core/replay_proxy.cpp @@ -2121,9 +2121,9 @@ void ReplayProxy::RemapProxyTextureIfNeeded(TextureDescription &tex, GetTextureD params.remap = RemapTexture::RGBA8; } - // since the texture type is unsupported, remove the bgraOrder flag and remap it to RGBA - if(tex.format.bgraOrder && m_APIProps.localRenderer == GraphicsAPI::OpenGL) - tex.format.bgraOrder = false; + // since the texture type is unsupported, remove the bgraOrder() flag and remap it to RGBA + if(tex.format.bgraOrder() && m_APIProps.localRenderer == GraphicsAPI::OpenGL) + tex.format.setBgraOrder(false); switch(params.remap) { diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 9b104d9c7..20070c901 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -1634,7 +1634,7 @@ bool WrappedID3D11Device::EndFrameCapture(void *dev, void *wnd) fp.pitch = mapped.RowPitch; fp.stride = fmt.compByteWidth * fmt.compCount; fp.bpc = fmt.compByteWidth; - fp.bgra = fmt.bgraOrder; + fp.bgra = fmt.bgraOrder(); fp.max_width = maxSize; fp.pitch_requirement = 8; switch(fmt.type) diff --git a/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp b/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp index 35f13cd4f..ebf0add2c 100644 --- a/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp +++ b/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp @@ -2470,7 +2470,7 @@ vector D3D11Replay::PixelHistory(vector events, R mod.postMod.col.floatValue[c] = ConvertFromHalf(uint16_t(mod.postMod.col.uintValue[c])); } } - else if(fmt.compType == CompType::UNorm && fmt.compByteWidth == 1 && fmt.srgbCorrected) + else if(fmt.compType == CompType::UNorm && fmt.compByteWidth == 1 && fmt.srgbCorrected()) { RDCASSERT(fmt.compByteWidth == 1); diff --git a/renderdoc/driver/d3d11/d3d11_postvs.cpp b/renderdoc/driver/d3d11/d3d11_postvs.cpp index 2d64dbfa2..679b48ea1 100644 --- a/renderdoc/driver/d3d11/d3d11_postvs.cpp +++ b/renderdoc/driver/d3d11/d3d11_postvs.cpp @@ -133,7 +133,6 @@ MeshFormat D3D11Replay::GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint ret.format.compByteWidth = 4; ret.format.compType = CompType::Float; ret.format.type = ResourceFormatType::Regular; - ret.format.bgraOrder = false; ret.showAlpha = false; diff --git a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp index 653824694..c844e3110 100644 --- a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp +++ b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp @@ -817,19 +817,19 @@ ShaderDebugTrace D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, uin } else if(fmt.type == ResourceFormatType::R5G5B5A1) { - RDCASSERT(fmt.bgraOrder); + RDCASSERT(fmt.bgraOrder()); uint16_t packed = ((uint16_t *)srcData)[0]; *v4 = ConvertFromB5G5R5A1(packed); } else if(fmt.type == ResourceFormatType::R5G6B5) { - RDCASSERT(fmt.bgraOrder); + RDCASSERT(fmt.bgraOrder()); uint16_t packed = ((uint16_t *)srcData)[0]; *v3 = ConvertFromB5G6R5(packed); } else if(fmt.type == ResourceFormatType::R4G4B4A4) { - RDCASSERT(fmt.bgraOrder); + RDCASSERT(fmt.bgraOrder()); uint16_t packed = ((uint16_t *)srcData)[0]; *v4 = ConvertFromB4G4R4A4(packed); } @@ -927,7 +927,7 @@ ShaderDebugTrace D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, uin } } - if(fmt.bgraOrder) + if(fmt.bgraOrder()) { RDCASSERT(fmt.compCount == 4); std::swap(ret.inputs[i].value.fv[2], ret.inputs[i].value.fv[0]); diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 23c22abc7..96c8743cc 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -1633,7 +1633,7 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd) fp.pitch = layout.Footprint.RowPitch; fp.stride = fmt.compByteWidth * fmt.compCount; fp.bpc = fmt.compByteWidth; - fp.bgra = fmt.bgraOrder; + fp.bgra = fmt.bgraOrder(); fp.max_width = maxSize; fp.pitch_requirement = 8; switch(fmt.type) diff --git a/renderdoc/driver/d3d12/d3d12_postvs.cpp b/renderdoc/driver/d3d12/d3d12_postvs.cpp index e03c1b1e1..997a9e961 100644 --- a/renderdoc/driver/d3d12/d3d12_postvs.cpp +++ b/renderdoc/driver/d3d12/d3d12_postvs.cpp @@ -1392,7 +1392,6 @@ MeshFormat D3D12Replay::GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint ret.format.compByteWidth = 4; ret.format.compType = CompType::Float; ret.format.type = ResourceFormatType::Regular; - ret.format.bgraOrder = false; ret.showAlpha = false; diff --git a/renderdoc/driver/dxgi/dxgi_common.cpp b/renderdoc/driver/dxgi/dxgi_common.cpp index 8487c8214..1b30ca3e4 100644 --- a/renderdoc/driver/dxgi/dxgi_common.cpp +++ b/renderdoc/driver/dxgi/dxgi_common.cpp @@ -1566,20 +1566,20 @@ DXGI_FORMAT MakeDXGIFormat(ResourceFormat fmt) case ResourceFormatType::R11G11B10: ret = DXGI_FORMAT_R11G11B10_FLOAT; break; case ResourceFormatType::R5G6B5: // only support bgra order - if(!fmt.bgraOrder) + if(!fmt.bgraOrder()) return DXGI_FORMAT_UNKNOWN; ret = DXGI_FORMAT_B5G6R5_UNORM; break; case ResourceFormatType::R5G5B5A1: // only support bgra order - if(!fmt.bgraOrder) + if(!fmt.bgraOrder()) return DXGI_FORMAT_UNKNOWN; ret = DXGI_FORMAT_B5G5R5A1_UNORM; break; case ResourceFormatType::R9G9B9E5: ret = DXGI_FORMAT_R9G9B9E5_SHAREDEXP; break; case ResourceFormatType::R4G4B4A4: // only support bgra order - if(!fmt.bgraOrder) + if(!fmt.bgraOrder()) return DXGI_FORMAT_UNKNOWN; ret = DXGI_FORMAT_B4G4R4A4_UNORM; break; @@ -1606,7 +1606,7 @@ DXGI_FORMAT MakeDXGIFormat(ResourceFormat fmt) else return DXGI_FORMAT_UNKNOWN; - if(fmt.bgraOrder) + if(fmt.bgraOrder()) ret = DXGI_FORMAT_B8G8R8A8_UNORM; } else if(fmt.compCount == 3) @@ -1660,7 +1660,7 @@ DXGI_FORMAT MakeDXGIFormat(ResourceFormat fmt) else return DXGI_FORMAT_UNKNOWN; - if(fmt.srgbCorrected) + if(fmt.srgbCorrected()) ret = GetSRGBFormat(ret); return ret; @@ -1673,7 +1673,7 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) ret.compCount = ret.compByteWidth = 0; ret.compType = CompType::Float; - ret.srgbCorrected = IsSRGBFormat(fmt); + ret.setSrgbCorrected(IsSRGBFormat(fmt)); switch(fmt) { @@ -2015,7 +2015,7 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8X8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: ret.bgraOrder = true; break; + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: ret.setBgraOrder(true); break; default: break; } @@ -2060,11 +2060,11 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) case DXGI_FORMAT_R11G11B10_FLOAT: ret.type = ResourceFormatType::R11G11B10; break; case DXGI_FORMAT_B5G6R5_UNORM: ret.type = ResourceFormatType::R5G6B5; - ret.bgraOrder = true; + ret.setBgraOrder(true); break; case DXGI_FORMAT_B5G5R5A1_UNORM: ret.type = ResourceFormatType::R5G5B5A1; - ret.bgraOrder = true; + ret.setBgraOrder(true); break; case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: ret.type = ResourceFormatType::R9G9B9E5; break; @@ -2089,7 +2089,7 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) case DXGI_FORMAT_B4G4R4A4_UNORM: ret.type = ResourceFormatType::R4G4B4A4; - ret.bgraOrder = true; + ret.setBgraOrder(true); break; case DXGI_FORMAT_UNKNOWN: ret.type = ResourceFormatType::Undefined; break; @@ -2249,7 +2249,7 @@ TEST_CASE("DXGI formats", "[format][d3d]") if(IsSRGBFormat(f)) { - CHECK(fmt.srgbCorrected); + CHECK(fmt.srgbCorrected()); } } }; @@ -2273,7 +2273,7 @@ TEST_CASE("DXGI formats", "[format][d3d]") ResourceFormat convfmt = MakeResourceFormat(conv); - CHECK(!convfmt.srgbCorrected); + CHECK(!convfmt.srgbCorrected()); } if(fmt.type == ResourceFormatType::BC1 || fmt.type == ResourceFormatType::BC2 || @@ -2288,7 +2288,7 @@ TEST_CASE("DXGI formats", "[format][d3d]") ResourceFormat convfmt = MakeResourceFormat(conv); - CHECK(convfmt.srgbCorrected); + CHECK(convfmt.srgbCorrected()); } if(f == DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM) @@ -2312,7 +2312,7 @@ TEST_CASE("DXGI formats", "[format][d3d]") DXGI_FORMAT typeless = GetTypelessFormat(f); DXGI_FORMAT typed = GetTypedFormat(typeless, typeHint); - if(fmt.srgbCorrected) + if(fmt.srgbCorrected()) typed = GetSRGBFormat(typed); CHECK(f == typed); diff --git a/renderdoc/driver/gl/gl_common.cpp b/renderdoc/driver/gl/gl_common.cpp index f371e287b..e2fabaf23 100644 --- a/renderdoc/driver/gl/gl_common.cpp +++ b/renderdoc/driver/gl/gl_common.cpp @@ -1736,7 +1736,7 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt) ret.compByteWidth = 1; ret.compCount = 1; ret.compType = CompType::UNorm; - ret.srgbCorrected = false; + ret.setSrgbCorrected(false); return ret; } @@ -1774,7 +1774,7 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt) case eGL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: case eGL_COMPRESSED_SRGB8_ETC2: case eGL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case eGL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: ret.srgbCorrected = true; break; + case eGL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: ret.setSrgbCorrected(true); break; default: break; } @@ -1918,7 +1918,7 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt) if(iscol == GL_TRUE) { if(fmt == eGL_BGRA8_EXT || fmt == eGL_BGRA) - ret.bgraOrder = true; + ret.setBgraOrder(true); // colour format @@ -1980,7 +1980,7 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt) } GL.glGetInternalformativ(target, fmt, eGL_COLOR_ENCODING, sizeof(GLint), &data[0]); - ret.srgbCorrected = (edata[0] == eGL_SRGB); + ret.setSrgbCorrected(edata[0] == eGL_SRGB); } else if(isdepth == GL_TRUE || isstencil == GL_TRUE) { @@ -2043,20 +2043,20 @@ GLenum MakeGLFormat(ResourceFormat fmt) case ResourceFormatType::BC1: { if(fmt.compCount == 3) - ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB_S3TC_DXT1_EXT - : eGL_COMPRESSED_RGB_S3TC_DXT1_EXT; + ret = fmt.srgbCorrected() ? eGL_COMPRESSED_SRGB_S3TC_DXT1_EXT + : eGL_COMPRESSED_RGB_S3TC_DXT1_EXT; else - ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT - : eGL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + ret = fmt.srgbCorrected() ? eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT + : eGL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break; } case ResourceFormatType::BC2: - ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT - : eGL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + ret = fmt.srgbCorrected() ? eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT + : eGL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break; case ResourceFormatType::BC3: - ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT - : eGL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + ret = fmt.srgbCorrected() ? eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT + : eGL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break; case ResourceFormatType::BC4: ret = fmt.compType == CompType::SNorm ? eGL_COMPRESSED_SIGNED_RED_RGTC1 @@ -2071,16 +2071,16 @@ GLenum MakeGLFormat(ResourceFormat fmt) : eGL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB; break; case ResourceFormatType::BC7: - ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB - : eGL_COMPRESSED_RGBA_BPTC_UNORM_ARB; + ret = fmt.srgbCorrected() ? eGL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB + : eGL_COMPRESSED_RGBA_BPTC_UNORM_ARB; break; case ResourceFormatType::ETC2: { if(fmt.compCount == 3) - ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB8_ETC2 : eGL_COMPRESSED_RGB8_ETC2; + ret = fmt.srgbCorrected() ? eGL_COMPRESSED_SRGB8_ETC2 : eGL_COMPRESSED_RGB8_ETC2; else - ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 - : eGL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + ret = fmt.srgbCorrected() ? eGL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 + : eGL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; break; } case ResourceFormatType::EAC: @@ -2092,8 +2092,8 @@ GLenum MakeGLFormat(ResourceFormat fmt) ret = fmt.compType == CompType::SNorm ? eGL_COMPRESSED_SIGNED_RG11_EAC : eGL_COMPRESSED_RG11_EAC; else - ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC - : eGL_COMPRESSED_RGBA8_ETC2_EAC; + ret = fmt.srgbCorrected() ? eGL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC + : eGL_COMPRESSED_RGBA8_ETC2_EAC; break; } case ResourceFormatType::R10G10B10A2: @@ -2117,11 +2117,11 @@ GLenum MakeGLFormat(ResourceFormat fmt) } else if(fmt.compCount == 4) { - if(fmt.srgbCorrected) + if(fmt.srgbCorrected()) { ret = eGL_SRGB8_ALPHA8; } - else if(fmt.bgraOrder) + else if(fmt.bgraOrder()) { ret = eGL_BGRA8_EXT; } @@ -2171,7 +2171,7 @@ GLenum MakeGLFormat(ResourceFormat fmt) } else if(fmt.compCount == 3) { - if(fmt.srgbCorrected) + if(fmt.srgbCorrected()) { ret = eGL_SRGB8; } diff --git a/renderdoc/driver/gl/gl_postvs.cpp b/renderdoc/driver/gl/gl_postvs.cpp index add292906..4e4c17655 100644 --- a/renderdoc/driver/gl/gl_postvs.cpp +++ b/renderdoc/driver/gl/gl_postvs.cpp @@ -1459,7 +1459,6 @@ MeshFormat GLReplay::GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint32_ ret.format.compByteWidth = 4; ret.format.compType = CompType::Float; ret.format.type = ResourceFormatType::Regular; - ret.format.bgraOrder = false; ret.showAlpha = false; diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 46a2cdc41..89fb52e28 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -858,7 +858,7 @@ void GLReplay::SavePipelineState() { fmt.compByteWidth = 1; fmt.compCount = 4; - fmt.bgraOrder = true; + fmt.setBgraOrder(true); fmt.compType = CompType::UNorm; if(type == eGL_UNSIGNED_INT_2_10_10_10_REV || type == eGL_INT_2_10_10_10_REV) @@ -2997,7 +2997,7 @@ ResourceId GLReplay::CreateProxyTexture(const TextureDescription &templateTex) } // Swizzle R/B channels only for non BGRA textures - if(templateTex.format.bgraOrder && target != eGL_NONE && baseFormat != eGL_BGRA) + if(templateTex.format.bgraOrder() && target != eGL_NONE && baseFormat != eGL_BGRA) { if(HasExt[ARB_texture_swizzle] || HasExt[EXT_texture_swizzle]) { @@ -3196,7 +3196,7 @@ bool GLReplay::IsTextureSupported(const ResourceFormat &format) // BGRA is not accepted as an internal format in case of GL // EXT_texture_format_BGRA8888 is required for creating BGRA proxy textures in case of GLES - if(format.bgraOrder) + if(format.bgraOrder()) return IsGLES && HasExt[EXT_texture_format_BGRA8888]; return true; diff --git a/renderdoc/driver/vulkan/vk_common.cpp b/renderdoc/driver/vulkan/vk_common.cpp index feff16798..cc4602e71 100644 --- a/renderdoc/driver/vulkan/vk_common.cpp +++ b/renderdoc/driver/vulkan/vk_common.cpp @@ -398,7 +398,6 @@ ResourceFormat MakeResourceFormat(VkFormat fmt) ret.compByteWidth = 0; ret.compCount = 0; ret.compType = CompType::Typeless; - ret.srgbCorrected = false; if(fmt == VK_FORMAT_UNDEFINED) { @@ -516,7 +515,7 @@ ResourceFormat MakeResourceFormat(VkFormat fmt) case VK_FORMAT_A2R10G10B10_USCALED_PACK32: case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: case VK_FORMAT_A2R10G10B10_UINT_PACK32: - case VK_FORMAT_A2R10G10B10_SINT_PACK32: ret.bgraOrder = true; break; + case VK_FORMAT_A2R10G10B10_SINT_PACK32: ret.setBgraOrder(true); break; default: break; } @@ -704,7 +703,7 @@ ResourceFormat MakeResourceFormat(VkFormat fmt) case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: - case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: ret.srgbCorrected = true; break; + case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: ret.setSrgbCorrected(true); break; default: break; } @@ -1011,16 +1010,16 @@ VkFormat MakeVkFormat(ResourceFormat fmt) case ResourceFormatType::BC1: { if(fmt.compCount == 3) - ret = fmt.srgbCorrected ? VK_FORMAT_BC1_RGB_SRGB_BLOCK : VK_FORMAT_BC1_RGB_UNORM_BLOCK; + ret = fmt.srgbCorrected() ? VK_FORMAT_BC1_RGB_SRGB_BLOCK : VK_FORMAT_BC1_RGB_UNORM_BLOCK; else - ret = fmt.srgbCorrected ? VK_FORMAT_BC1_RGBA_SRGB_BLOCK : VK_FORMAT_BC1_RGBA_UNORM_BLOCK; + ret = fmt.srgbCorrected() ? VK_FORMAT_BC1_RGBA_SRGB_BLOCK : VK_FORMAT_BC1_RGBA_UNORM_BLOCK; break; } case ResourceFormatType::BC2: - ret = fmt.srgbCorrected ? VK_FORMAT_BC2_SRGB_BLOCK : VK_FORMAT_BC2_UNORM_BLOCK; + ret = fmt.srgbCorrected() ? VK_FORMAT_BC2_SRGB_BLOCK : VK_FORMAT_BC2_UNORM_BLOCK; break; case ResourceFormatType::BC3: - ret = fmt.srgbCorrected ? VK_FORMAT_BC3_SRGB_BLOCK : VK_FORMAT_BC3_UNORM_BLOCK; + ret = fmt.srgbCorrected() ? VK_FORMAT_BC3_SRGB_BLOCK : VK_FORMAT_BC3_UNORM_BLOCK; break; case ResourceFormatType::BC4: ret = fmt.compType == CompType::SNorm ? VK_FORMAT_BC4_SNORM_BLOCK : VK_FORMAT_BC4_UNORM_BLOCK; @@ -1033,16 +1032,16 @@ VkFormat MakeVkFormat(ResourceFormat fmt) : VK_FORMAT_BC6H_UFLOAT_BLOCK; break; case ResourceFormatType::BC7: - ret = fmt.srgbCorrected ? VK_FORMAT_BC7_SRGB_BLOCK : VK_FORMAT_BC7_UNORM_BLOCK; + ret = fmt.srgbCorrected() ? VK_FORMAT_BC7_SRGB_BLOCK : VK_FORMAT_BC7_UNORM_BLOCK; break; case ResourceFormatType::ETC2: { if(fmt.compCount == 3) - ret = fmt.srgbCorrected ? VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK - : VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; + ret = fmt.srgbCorrected() ? VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK + : VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; else - ret = fmt.srgbCorrected ? VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK - : VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; + ret = fmt.srgbCorrected() ? VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK + : VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; break; } case ResourceFormatType::EAC: @@ -1057,30 +1056,32 @@ VkFormat MakeVkFormat(ResourceFormat fmt) } case ResourceFormatType::R10G10B10A2: if(fmt.compType == CompType::UNorm) - ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_UNORM_PACK32 - : VK_FORMAT_A2B10G10R10_UNORM_PACK32; + ret = fmt.bgraOrder() ? VK_FORMAT_A2R10G10B10_UNORM_PACK32 + : VK_FORMAT_A2B10G10R10_UNORM_PACK32; else if(fmt.compType == CompType::UInt) - ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_UINT_PACK32 : VK_FORMAT_A2B10G10R10_UINT_PACK32; + ret = fmt.bgraOrder() ? VK_FORMAT_A2R10G10B10_UINT_PACK32 + : VK_FORMAT_A2B10G10R10_UINT_PACK32; else if(fmt.compType == CompType::UScaled) - ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_USCALED_PACK32 - : VK_FORMAT_A2B10G10R10_USCALED_PACK32; + ret = fmt.bgraOrder() ? VK_FORMAT_A2R10G10B10_USCALED_PACK32 + : VK_FORMAT_A2B10G10R10_USCALED_PACK32; else if(fmt.compType == CompType::SNorm) - ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_SNORM_PACK32 - : VK_FORMAT_A2B10G10R10_SNORM_PACK32; + ret = fmt.bgraOrder() ? VK_FORMAT_A2R10G10B10_SNORM_PACK32 + : VK_FORMAT_A2B10G10R10_SNORM_PACK32; else if(fmt.compType == CompType::SInt) - ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_SINT_PACK32 : VK_FORMAT_A2B10G10R10_SINT_PACK32; + ret = fmt.bgraOrder() ? VK_FORMAT_A2R10G10B10_SINT_PACK32 + : VK_FORMAT_A2B10G10R10_SINT_PACK32; else if(fmt.compType == CompType::SScaled) - ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_SSCALED_PACK32 - : VK_FORMAT_A2B10G10R10_SSCALED_PACK32; + ret = fmt.bgraOrder() ? VK_FORMAT_A2R10G10B10_SSCALED_PACK32 + : VK_FORMAT_A2B10G10R10_SSCALED_PACK32; break; case ResourceFormatType::R11G11B10: ret = VK_FORMAT_B10G11R11_UFLOAT_PACK32; break; case ResourceFormatType::R5G6B5: ret = VK_FORMAT_B5G6R5_UNORM_PACK16; break; case ResourceFormatType::R5G5B5A1: - ret = fmt.bgraOrder ? VK_FORMAT_B5G5R5A1_UNORM_PACK16 : VK_FORMAT_R5G5B5A1_UNORM_PACK16; + ret = fmt.bgraOrder() ? VK_FORMAT_B5G5R5A1_UNORM_PACK16 : VK_FORMAT_R5G5B5A1_UNORM_PACK16; break; case ResourceFormatType::R9G9B9E5: ret = VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; break; case ResourceFormatType::R4G4B4A4: - ret = fmt.bgraOrder ? VK_FORMAT_R4G4B4A4_UNORM_PACK16 : VK_FORMAT_B4G4R4A4_UNORM_PACK16; + ret = fmt.bgraOrder() ? VK_FORMAT_R4G4B4A4_UNORM_PACK16 : VK_FORMAT_B4G4R4A4_UNORM_PACK16; break; case ResourceFormatType::R4G4: ret = VK_FORMAT_R4G4_UNORM_PACK8; break; case ResourceFormatType::D24S8: ret = VK_FORMAT_D24_UNORM_S8_UINT; break; @@ -1090,9 +1091,9 @@ VkFormat MakeVkFormat(ResourceFormat fmt) } else if(fmt.compCount == 4) { - if(fmt.srgbCorrected) + if(fmt.srgbCorrected()) { - ret = fmt.bgraOrder ? VK_FORMAT_B8G8R8A8_SRGB : VK_FORMAT_R8G8B8A8_SRGB; + ret = fmt.bgraOrder() ? VK_FORMAT_B8G8R8A8_SRGB : VK_FORMAT_R8G8B8A8_SRGB; } else if(fmt.compByteWidth == 8) { @@ -1138,17 +1139,17 @@ VkFormat MakeVkFormat(ResourceFormat fmt) else if(fmt.compByteWidth == 1) { if(fmt.compType == CompType::SInt) - ret = fmt.bgraOrder ? VK_FORMAT_B8G8R8A8_SINT : VK_FORMAT_R8G8B8A8_SINT; + ret = fmt.bgraOrder() ? VK_FORMAT_B8G8R8A8_SINT : VK_FORMAT_R8G8B8A8_SINT; else if(fmt.compType == CompType::UInt) - ret = fmt.bgraOrder ? VK_FORMAT_B8G8R8A8_UINT : VK_FORMAT_R8G8B8A8_UINT; + ret = fmt.bgraOrder() ? VK_FORMAT_B8G8R8A8_UINT : VK_FORMAT_R8G8B8A8_UINT; else if(fmt.compType == CompType::SNorm) - ret = fmt.bgraOrder ? VK_FORMAT_B8G8R8A8_SNORM : VK_FORMAT_R8G8B8A8_SNORM; + ret = fmt.bgraOrder() ? VK_FORMAT_B8G8R8A8_SNORM : VK_FORMAT_R8G8B8A8_SNORM; else if(fmt.compType == CompType::UNorm) - ret = fmt.bgraOrder ? VK_FORMAT_B8G8R8A8_UNORM : VK_FORMAT_R8G8B8A8_UNORM; + ret = fmt.bgraOrder() ? VK_FORMAT_B8G8R8A8_UNORM : VK_FORMAT_R8G8B8A8_UNORM; else if(fmt.compType == CompType::SScaled) - ret = fmt.bgraOrder ? VK_FORMAT_B8G8R8A8_SSCALED : VK_FORMAT_R8G8B8A8_SSCALED; + ret = fmt.bgraOrder() ? VK_FORMAT_B8G8R8A8_SSCALED : VK_FORMAT_R8G8B8A8_SSCALED; else if(fmt.compType == CompType::UScaled) - ret = fmt.bgraOrder ? VK_FORMAT_B8G8R8A8_USCALED : VK_FORMAT_R8G8B8A8_USCALED; + ret = fmt.bgraOrder() ? VK_FORMAT_B8G8R8A8_USCALED : VK_FORMAT_R8G8B8A8_USCALED; else RDCERR("Unrecognised component type"); } @@ -1159,7 +1160,7 @@ VkFormat MakeVkFormat(ResourceFormat fmt) } else if(fmt.compCount == 3) { - if(fmt.srgbCorrected) + if(fmt.srgbCorrected()) { ret = VK_FORMAT_R8G8B8_SRGB; } diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index 1d5f4c814..c192f9023 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -1576,7 +1576,7 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd) fp.pitch = rowPitch; fp.stride = fmt.compByteWidth * fmt.compCount; fp.bpc = fmt.compByteWidth; - fp.bgra = fmt.bgraOrder; + fp.bgra = fmt.bgraOrder(); fp.max_width = maxSize; fp.pitch_requirement = 8; switch(fmt.type) diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index 64e741559..e082f40d0 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -3250,7 +3250,6 @@ MeshFormat VulkanReplay::GetPostVSBuffers(uint32_t eventId, uint32_t instID, uin ret.format.compByteWidth = 4; ret.format.compType = CompType::Float; ret.format.type = ResourceFormatType::Regular; - ret.format.bgraOrder = false; ret.showAlpha = false; diff --git a/renderdoc/replay/entry_points.cpp b/renderdoc/replay/entry_points.cpp index ee1fb7141..4d46ee213 100644 --- a/renderdoc/replay/entry_points.cpp +++ b/renderdoc/replay/entry_points.cpp @@ -620,15 +620,15 @@ static std::string ResourceFormatName(const ResourceFormat &fmt) case ResourceFormatType::BC1: if(fmt.compType == CompType::Typeless) return "BC1_TYPELESS"; - return fmt.srgbCorrected ? "BC1_SRGB" : "BC1_UNORM"; + return fmt.srgbCorrected() ? "BC1_SRGB" : "BC1_UNORM"; case ResourceFormatType::BC2: if(fmt.compType == CompType::Typeless) return "BC2_TYPELESS"; - return fmt.srgbCorrected ? "BC2_SRGB" : "BC2_UNORM"; + return fmt.srgbCorrected() ? "BC2_SRGB" : "BC2_UNORM"; case ResourceFormatType::BC3: if(fmt.compType == CompType::Typeless) return "BC3_TYPELESS"; - return fmt.srgbCorrected ? "BC3_SRGB" : "BC3_UNORM"; + return fmt.srgbCorrected() ? "BC3_SRGB" : "BC3_UNORM"; case ResourceFormatType::BC4: if(fmt.compType == CompType::Typeless) return "BC4_TYPELESS"; @@ -644,8 +644,8 @@ static std::string ResourceFormatName(const ResourceFormat &fmt) case ResourceFormatType::BC7: if(fmt.compType == CompType::Typeless) return "BC7_TYPELESS"; - return fmt.srgbCorrected ? "BC7_SRGB" : "BC7_UNORM"; - case ResourceFormatType::ETC2: return fmt.srgbCorrected ? "ETC2_SRGB" : "ETC_UNORM"; + return fmt.srgbCorrected() ? "BC7_SRGB" : "BC7_UNORM"; + case ResourceFormatType::ETC2: return fmt.srgbCorrected() ? "ETC2_SRGB" : "ETC_UNORM"; case ResourceFormatType::EAC: { if(fmt.compCount == 1) @@ -654,17 +654,19 @@ static std::string ResourceFormatName(const ResourceFormat &fmt) return fmt.compType == CompType::UNorm ? "EAC_RG_UNORM" : "EAC_RG_SNORM"; } case ResourceFormatType::ASTC: - return fmt.srgbCorrected ? "ASTC_SRGB" : "ASTC_UNORM"; + return fmt.srgbCorrected() ? "ASTC_SRGB" : "ASTC_UNORM"; // 10:10:10 A2 is the only format that can have all the usual format types (unorm, snorm, // etc). So we break and handle it like any other format below. case ResourceFormatType::R10G10B10A2: - ret = fmt.bgraOrder ? "B10G10R10A2" : "R10G10B10A2"; + ret = fmt.bgraOrder() ? "B10G10R10A2" : "R10G10B10A2"; break; case ResourceFormatType::R11G11B10: return "R11G11B10_FLOAT"; - case ResourceFormatType::R5G6B5: return fmt.bgraOrder ? "R5G6B5_UNORM" : "B5G6R5_UNORM"; - case ResourceFormatType::R5G5B5A1: return fmt.bgraOrder ? "R5G5B5A1_UNORM" : "B5G5R5A1_UNORM"; + case ResourceFormatType::R5G6B5: return fmt.bgraOrder() ? "R5G6B5_UNORM" : "B5G6R5_UNORM"; + case ResourceFormatType::R5G5B5A1: + return fmt.bgraOrder() ? "R5G5B5A1_UNORM" : "B5G5R5A1_UNORM"; case ResourceFormatType::R9G9B9E5: return "R9G9B9E5_FLOAT"; - case ResourceFormatType::R4G4B4A4: return fmt.bgraOrder ? "R4G4B4A4_UNORM" : "B4G4R4A4_UNORM"; + case ResourceFormatType::R4G4B4A4: + return fmt.bgraOrder() ? "R4G4B4A4_UNORM" : "B4G4R4A4_UNORM"; case ResourceFormatType::R4G4: return "R4G4_UNORM"; case ResourceFormatType::D16S8: return fmt.compType == CompType::Typeless ? "D16S8_TYPELESS" : "D16S8"; @@ -685,14 +687,14 @@ static std::string ResourceFormatName(const ResourceFormat &fmt) { char comps[] = "RGBA"; - if(fmt.bgraOrder) + if(fmt.bgraOrder()) std::swap(comps[0], comps[2]); for(uint32_t i = 0; i < fmt.compCount; i++) ret += StringFormat::Fmt("%c%u", comps[i], fmt.compByteWidth * 8); } - if(fmt.srgbCorrected) + if(fmt.srgbCorrected()) return ret + "_SRGB"; switch(fmt.compType) diff --git a/renderdoc/replay/renderdoc_serialise.inl b/renderdoc/replay/renderdoc_serialise.inl index 48366a759..4bbaab948 100644 --- a/renderdoc/replay/renderdoc_serialise.inl +++ b/renderdoc/replay/renderdoc_serialise.inl @@ -122,8 +122,7 @@ void DoSerialise(SerialiserType &ser, ResourceFormat &el) SERIALISE_MEMBER(compType); SERIALISE_MEMBER(compCount); SERIALISE_MEMBER(compByteWidth); - SERIALISE_MEMBER(bgraOrder); - SERIALISE_MEMBER(srgbCorrected); + SERIALISE_MEMBER(flags); SIZE_CHECK(6); } diff --git a/renderdoc/replay/replay_controller.cpp b/renderdoc/replay/replay_controller.cpp index 9b85c6162..ab5f0661c 100644 --- a/renderdoc/replay/replay_controller.cpp +++ b/renderdoc/replay/replay_controller.cpp @@ -140,7 +140,7 @@ float ConvertComponent(const ResourceFormat &fmt, const byte *data) } else if(fmt.compType == CompType::UNorm) { - if(fmt.srgbCorrected) + if(fmt.srgbCorrected()) return SRGB8_lookuptable[*u8]; else return float(*u8) / 255.0f; @@ -793,7 +793,7 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path // for non-HDR always downcast if we're not already RGBA8 unorm if(sd.destType != FileType::DDS && sd.destType != FileType::HDR && sd.destType != FileType::EXR && (td.format.compByteWidth != 1 || td.format.compCount != 4 || - td.format.compType != CompType::UNorm || td.format.bgraOrder)) + td.format.compType != CompType::UNorm || td.format.bgraOrder())) downcast = true; // for HDR & EXR we can convert from most regular types as well as 10.10.10.2 and 11.11.10 @@ -1363,7 +1363,7 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path srcData += pixStride; } - if(saveFmt.bgraOrder) + if(saveFmt.bgraOrder()) std::swap(r, b); // HDR can't represent negative values diff --git a/renderdoc/replay/replay_driver.cpp b/renderdoc/replay/replay_driver.cpp index af0146722..b0002b999 100644 --- a/renderdoc/replay/replay_driver.cpp +++ b/renderdoc/replay/replay_driver.cpp @@ -351,7 +351,7 @@ FloatVector HighlightCache::InterpretVertex(const byte *data, uint32_t vert, out++; } - if(fmt.bgraOrder) + if(fmt.bgraOrder()) { FloatVector reversed; reversed.x = ret.z;