@@ -41,22 +41,6 @@ static_assert(sizeof(g_formats_dx) / sizeof(g_formats_dx[0]) == size_t(eTexForma
4141
4242uint32_t TextureHandleCounter = 0 ;
4343
44- DXGI_FORMAT ToSRGBFormat (const DXGI_FORMAT format) {
45- switch (format) {
46- case DXGI_FORMAT_R8G8B8A8_UNORM:
47- return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
48- case DXGI_FORMAT_BC1_UNORM:
49- return DXGI_FORMAT_BC1_UNORM_SRGB;
50- case DXGI_FORMAT_BC2_UNORM:
51- return DXGI_FORMAT_BC2_UNORM_SRGB;
52- case DXGI_FORMAT_BC3_UNORM:
53- return DXGI_FORMAT_BC3_UNORM_SRGB;
54- default :
55- return format;
56- }
57- return DXGI_FORMAT_UNKNOWN;
58- }
59-
6044D3D12_RESOURCE_FLAGS to_dx_image_flags (const Bitmask<eTexUsage> usage, const eTexFormat format) {
6145 D3D12_RESOURCE_FLAGS ret = D3D12_RESOURCE_FLAG_NONE;
6246 if (usage & eTexUsage::Storage) {
@@ -171,8 +155,7 @@ void Ray::Dx::Texture::Free() {
171155}
172156
173157bool Ray::Dx::Texture::Realloc (const int w, const int h, int mip_count, const int samples, const eTexFormat format,
174- const bool is_srgb, ID3D12GraphicsCommandList *cmd_buf, MemAllocators *mem_allocs,
175- ILog *log) {
158+ ID3D12GraphicsCommandList *cmd_buf, MemAllocators *mem_allocs, ILog *log) {
176159 ID3D12Resource *new_image = nullptr ;
177160 // VkImageView new_image_view = VK_NULL_HANDLE;
178161 MemAllocation new_alloc = {};
@@ -186,9 +169,6 @@ bool Ray::Dx::Texture::Realloc(const int w, const int h, int mip_count, const in
186169 image_desc.DepthOrArraySize = 1 ;
187170 image_desc.MipLevels = mip_count;
188171 image_desc.Format = g_formats_dx[int (format)];
189- if (is_srgb) {
190- image_desc.Format = ToSRGBFormat (image_desc.Format );
191- }
192172 image_desc.SampleDesc .Count = samples;
193173 image_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
194174 image_desc.Flags = to_dx_image_flags (Bitmask<eTexUsage>{params.usage }, format);
@@ -247,9 +227,6 @@ bool Ray::Dx::Texture::Realloc(const int w, const int h, int mip_count, const in
247227 view_info.image = new_image;
248228 view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
249229 view_info.format = g_formats_vk[size_t(format)];
250- if (is_srgb) {
251- view_info.format = ToSRGBFormat(view_info.format);
252- }
253230 view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
254231 view_info.subresourceRange.baseMipLevel = 0;
255232 view_info.subresourceRange.levelCount = mip_count;
@@ -399,11 +376,6 @@ bool Ray::Dx::Texture::Realloc(const int w, const int h, int mip_count, const in
399376 alloc_ = std::move(new_alloc);
400377 params.w = w;
401378 params.h = h;
402- if (is_srgb) {
403- params.flags |= eTexFlagBits::SRGB;
404- } else {
405- params.flags &= ~eTexFlagBits::SRGB;
406- }
407379 params.mip_count = mip_count;
408380 params.samples = samples;
409381 params.format = format;
@@ -430,9 +402,6 @@ void Ray::Dx::Texture::InitFromRAWData(Buffer *sbuf, int data_off, ID3D12Graphic
430402 image_desc.DepthOrArraySize = (p.d ? p.d : 1 );
431403 image_desc.MipLevels = params.mip_count ;
432404 image_desc.Format = g_formats_dx[int (p.format )];
433- if (p.flags & eTexFlags::SRGB) {
434- image_desc.Format = ToSRGBFormat (image_desc.Format );
435- }
436405 image_desc.SampleDesc .Count = p.samples ;
437406 image_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
438407 image_desc.Flags = to_dx_image_flags (Bitmask<eTexUsage>{params.usage }, p.format );
@@ -471,9 +440,6 @@ void Ray::Dx::Texture::InitFromRAWData(Buffer *sbuf, int data_off, ID3D12Graphic
471440 { // create default SRV
472441 D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = {};
473442 srv_desc.Format = g_formats_dx[int (p.format )];
474- if (p.flags & eTexFlags::SRGB) {
475- srv_desc.Format = ToSRGBFormat (srv_desc.Format );
476- }
477443 if (p.d == 0 ) {
478444 srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
479445 srv_desc.Texture2D .MipLevels = p.mip_count ;
@@ -679,9 +645,6 @@ void Ray::Dx::Texture::SetSubImage(const int level, const int offsetx, const int
679645 src_loc.PlacedFootprint .Footprint .Height = sizey;
680646 src_loc.PlacedFootprint .Footprint .Depth = sizez;
681647 src_loc.PlacedFootprint .Footprint .Format = g_formats_dx[int (params.format )];
682- if (Bitmask<eTexFlags>{params.flags } & eTexFlags::SRGB) {
683- src_loc.PlacedFootprint .Footprint .Format = ToSRGBFormat (src_loc.PlacedFootprint .Footprint .Format );
684- }
685648 if (IsCompressedFormat (params.format )) {
686649 src_loc.PlacedFootprint .Footprint .RowPitch = round_up (
687650 GetBlockCount (sizex, 1 , params.format ) * GetBlockLenBytes (params.format ), TextureDataPitchAlignment);
@@ -884,11 +847,6 @@ void Ray::Dx::_ClearColorImage(Texture &tex, const void *rgba, ID3D12GraphicsCom
884847
885848DXGI_FORMAT Ray::Dx::DXFormatFromTexFormat (const eTexFormat format) { return g_formats_dx[size_t (format)]; }
886849
887- bool Ray::Dx::RequiresManualSRGBConversion (const eTexFormat format) {
888- const DXGI_FORMAT dxgi_format = g_formats_dx[size_t (format)];
889- return dxgi_format == ToSRGBFormat (dxgi_format);
890- }
891-
892850bool Ray::Dx::CanBeBlockCompressed (int w, int h, const int mip_count) {
893851 // NOTE: Assume only BC-formats for now
894852 static const int block_res[2 ] = {4 , 4 };
0 commit comments