From: "Conor McCarthy" Subject: Re: [PATCH vkd3d v2 1/2] vkd3d: Return success for all valid D3D12 alignments. Message-Id: Date: Tue, 26 Nov 2019 12:44:20 +0000 In-Reply-To: References: <20191125065944.13942-1-cmccarthy@codeweavers.com> <749d54c8278ec0d4a1f1e2478389ba36@codeweavers.com> November 26, 2019 10:24 PM, "Henri Verbeet" wrote: > On Tue, 26 Nov 2019 at 15:04, Conor McCarthy wrote: > >> How about this: >> estimated_size = (desc->Height / format->block_height) * (desc->Width / format->block_width) >> * format->byte_count * format->block_byte_count; > > That will result in a 0 estimated size for textures with any dimension > smaller than the block size. That would be fine for e.g. a 1x1 texture > since the total size would be smaller than > D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT anyway, but note that that > would also affect textures that are e.g. very wide but only 1 pixel > tall. When I was messing with this in Windows I think a resource was invalid if any dimension was not aligned with the block size in that dimension. I didn't check tiny dimensions, or if 1D textures are valid at all with a compressed format. I'll test all of these. But in any case the following should work. With dimension limits there's no chance of overflow. estimated_size = desc->Width * desc->Height * format->byte_count * format->block_byte_count / (format->block_width * format->block_height);