Calculate texture byte sizes as 64-bit on GL and Vulkan. Closes #3338

This commit is contained in:
baldurk
2024-06-03 12:02:45 +01:00
parent 44f9f24ace
commit aecaa7e208
12 changed files with 114 additions and 67 deletions
+28 -24
View File
@@ -89,45 +89,47 @@ size_t GetCompressedByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum internalfor
uint32_t astc[3] = {0, 0, 1u};
size_t numBlockAlignedTexels = size_t(AlignUp4(w)) * size_t(AlignUp4(h)) * size_t(d);
switch(internalformat)
{
// BC1
case eGL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case eGL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case eGL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return (AlignUp4(w) * AlignUp4(h) * d) / 2;
case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return numBlockAlignedTexels / 2;
// BC2
case eGL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return (AlignUp4(w) * AlignUp4(h) * d);
case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return numBlockAlignedTexels;
// BC3
case eGL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return (AlignUp4(w) * AlignUp4(h) * d);
case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return numBlockAlignedTexels;
// BC4
case eGL_COMPRESSED_RED_RGTC1:
case eGL_COMPRESSED_SIGNED_RED_RGTC1: return (AlignUp4(w) * AlignUp4(h) * d) / 2;
case eGL_COMPRESSED_SIGNED_RED_RGTC1: return numBlockAlignedTexels / 2;
// BC5
case eGL_COMPRESSED_RG_RGTC2:
case eGL_COMPRESSED_SIGNED_RG_RGTC2: return (AlignUp4(w) * AlignUp4(h) * d);
case eGL_COMPRESSED_SIGNED_RG_RGTC2: return numBlockAlignedTexels;
// BC6
case eGL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB:
case eGL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB: return (AlignUp4(w) * AlignUp4(h) * d);
case eGL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB: return numBlockAlignedTexels;
// BC7
case eGL_COMPRESSED_RGBA_BPTC_UNORM_ARB:
case eGL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: return (AlignUp4(w) * AlignUp4(h) * d);
case eGL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: return numBlockAlignedTexels;
// ETC1
case eGL_ETC1_RGB8_OES:
// ETC2
case eGL_COMPRESSED_RGB8_ETC2:
case eGL_COMPRESSED_SRGB8_ETC2:
case eGL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
case eGL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return (AlignUp4(w) * AlignUp4(h) * d) / 2;
case eGL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return numBlockAlignedTexels / 2;
// EAC
case eGL_COMPRESSED_RGBA8_ETC2_EAC:
case eGL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: return (AlignUp4(w) * AlignUp4(h) * d);
case eGL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: return numBlockAlignedTexels;
case eGL_COMPRESSED_R11_EAC:
case eGL_COMPRESSED_SIGNED_R11_EAC: return (AlignUp4(w) * AlignUp4(h) * d) / 2;
case eGL_COMPRESSED_SIGNED_R11_EAC: return numBlockAlignedTexels / 2;
case eGL_COMPRESSED_RG11_EAC:
case eGL_COMPRESSED_SIGNED_RG11_EAC: return (AlignUp4(w) * AlignUp4(h) * d);
case eGL_COMPRESSED_SIGNED_RG11_EAC: return numBlockAlignedTexels;
// ASTC
case eGL_COMPRESSED_RGBA_ASTC_4x4_KHR:
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
@@ -263,17 +265,17 @@ size_t GetCompressedByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum internalfor
case eGL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:
case eGL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:
// 4x8 block in 8 bytes = 32 pixels in 8 bytes = 0.25 bytes per pixel
return (AlignUp(w, 4) * AlignUp(h, 8) * d) / 4;
return (size_t(AlignUp(w, 4)) * size_t(AlignUp(h, 8)) * size_t(d)) / 4;
case eGL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:
case eGL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:
// 4x4 block in 8 bytes = 16 pixels in 8 bytes = 0.5 bytes per pixel
return (AlignUp(w, 4) * AlignUp(h, 4) * d) / 2;
return numBlockAlignedTexels / 2;
default: break;
}
if(astc[0] > 0 && astc[1] > 0 && astc[2] > 0)
{
uint32_t blocks[3] = {(w / astc[0]), (h / astc[1]), (d / astc[2])};
size_t blocks[3] = {(w / astc[0]), (h / astc[1]), (d / astc[2])};
// how many blocks are needed - including any extra partial blocks
blocks[0] += (w % astc[0]) ? 1 : 0;
@@ -489,6 +491,8 @@ size_t GetByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum format, GLenum type)
{
size_t elemSize = 1;
size_t numTexels = size_t(w) * size_t(h) * size_t(d);
switch(type)
{
case eGL_UNSIGNED_BYTE:
@@ -502,28 +506,28 @@ size_t GetByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum format, GLenum type)
case eGL_FLOAT: elemSize = 4; break;
case eGL_DOUBLE: elemSize = 8; break;
case eGL_UNSIGNED_BYTE_3_3_2:
case eGL_UNSIGNED_BYTE_2_3_3_REV: return w * h * d;
case eGL_UNSIGNED_BYTE_2_3_3_REV: return numTexels;
case eGL_UNSIGNED_SHORT_5_6_5:
case eGL_UNSIGNED_SHORT_5_6_5_REV:
case eGL_UNSIGNED_SHORT_4_4_4_4:
case eGL_UNSIGNED_SHORT_4_4_4_4_REV:
case eGL_UNSIGNED_SHORT_5_5_5_1:
case eGL_UNSIGNED_SHORT_1_5_5_5_REV: return w * h * d * 2;
case eGL_UNSIGNED_SHORT_1_5_5_5_REV: return numTexels * 2;
case eGL_UNSIGNED_INT_8_8_8_8:
case eGL_UNSIGNED_INT_8_8_8_8_REV:
case eGL_UNSIGNED_INT_10_10_10_2:
case eGL_UNSIGNED_INT_2_10_10_10_REV:
case eGL_INT_2_10_10_10_REV:
case eGL_UNSIGNED_INT_10F_11F_11F_REV:
case eGL_UNSIGNED_INT_5_9_9_9_REV: return w * h * d * 4;
case eGL_DEPTH_COMPONENT16: return w * h * d * 2;
case eGL_UNSIGNED_INT_5_9_9_9_REV: return numTexels * 4;
case eGL_DEPTH_COMPONENT16: return numTexels * 2;
case eGL_DEPTH_COMPONENT24:
case eGL_DEPTH24_STENCIL8:
case eGL_DEPTH_COMPONENT32:
case eGL_DEPTH_COMPONENT32F:
case eGL_UNSIGNED_INT_24_8: return w * h * d * 4;
case eGL_UNSIGNED_INT_24_8: return numTexels * 4;
case eGL_DEPTH32F_STENCIL8:
case eGL_FLOAT_32_UNSIGNED_INT_24_8_REV: return w * h * d * 8;
case eGL_FLOAT_32_UNSIGNED_INT_24_8_REV: return numTexels * 8;
default: RDCERR("Unhandled Byte Size type %s!", ToStr(type).c_str()); break;
}
@@ -540,21 +544,21 @@ size_t GetByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum format, GLenum type)
case eGL_ALPHA_INTEGER:
case eGL_DEPTH_COMPONENT:
case eGL_STENCIL_INDEX:
case eGL_STENCIL: return w * h * d * elemSize;
case eGL_STENCIL: return numTexels * elemSize;
case eGL_RG:
case eGL_RG_INTEGER:
case eGL_LUMINANCE_ALPHA:
case eGL_DEPTH_STENCIL: return w * h * d * elemSize * 2;
case eGL_DEPTH_STENCIL: return numTexels * elemSize * 2;
case eGL_RGB:
case eGL_RGB_INTEGER:
case eGL_BGR:
case eGL_BGR_INTEGER:
case eGL_SRGB: return w * h * d * elemSize * 3;
case eGL_SRGB: return numTexels * elemSize * 3;
case eGL_RGBA:
case eGL_RGBA_INTEGER:
case eGL_BGRA:
case eGL_BGRA_INTEGER:
case eGL_SRGB_ALPHA: return w * h * d * elemSize * 4;
case eGL_SRGB_ALPHA: return numTexels * elemSize * 4;
default: RDCERR("Unhandled Byte Size format %s!", ToStr(format).c_str()); break;
}
+13 -3
View File
@@ -2421,7 +2421,7 @@ bool WrappedVulkan::EndFrameCapture(DeviceOwnedWindow devWnd)
vkr = vt->BeginCommandBuffer(Unwrap(cmd), &beginInfo);
CheckVkResult(vkr);
uint32_t rowPitch = GetByteSize(imageInfo.extent.width, 1, 1, imageInfo.format, 0);
uint32_t rowPitch = (uint32_t)GetByteSize(imageInfo.extent.width, 1, 1, imageInfo.format, 0);
VkBufferImageCopy cpy = {
0,
@@ -2686,8 +2686,18 @@ bool WrappedVulkan::EndFrameCapture(DeviceOwnedWindow devWnd)
captureSectionSize = captureWriter->GetOffset();
}
RDCLOG("Captured Vulkan frame with %f MB capture section in %f seconds",
double(captureSectionSize) / (1024.0 * 1024.0), m_CaptureTimer.GetMilliseconds() / 1000.0);
if(m_CaptureFailure)
{
m_LastCaptureFailed = Timing::GetUnixTimestamp();
SAFE_DELETE(rdc);
}
else
{
RDCLOG("Captured Vulkan frame with %f MB capture section in %f seconds",
double(captureSectionSize) / (1024.0 * 1024.0), m_CaptureTimer.GetMilliseconds() / 1000.0);
}
m_CaptureFailure = false;
RenderDoc::Inst().FinishCaptureWriting(rdc, m_CapturedFrames.back().frameNumber);
+41 -11
View File
@@ -69,7 +69,7 @@ void VulkanDebugManager::CopyTex2DMSToBuffer(VkCommandBuffer cmd, VkBuffer destB
},
};
uint32_t bs = GetByteSize(1, 1, 1, fmt, 0);
uint32_t bs = (uint32_t)GetByteSize(1, 1, 1, fmt, 0);
if(bs == 1)
viewInfo.format = VK_FORMAT_R8_UINT;
@@ -114,9 +114,13 @@ void VulkanDebugManager::CopyTex2DMSToBuffer(VkCommandBuffer cmd, VkBuffer destB
ObjDisp(cmd)->CmdBindPipeline(Unwrap(cmd), VK_PIPELINE_BIND_POINT_COMPUTE,
Unwrap(m_MS2BufferPipe));
const uint32_t dispatchBufferSize =
const uint64_t dispatchBufferSize =
GetByteSize(extent.width, extent.height, extent.depth, fmt, 0);
uint32_t dispatchOffset = 0;
uint64_t dispatchOffset = 0;
RDCASSERTMSG("More than 32-bit offset required for CopyTex2DMSToBuffer",
uint64_t(numSlices) * uint64_t(numSamples) * dispatchBufferSize < 0xffffffffULL,
numSlices, numSamples, extent, fmt);
VkDescriptorImageInfo srcdesc = {0};
srcdesc.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
@@ -157,7 +161,7 @@ void VulkanDebugManager::CopyTex2DMSToBuffer(VkCommandBuffer cmd, VkBuffer destB
Vec4u params[2] = {
{extent.width, currentSlice, currentSample, bs},
{maxInvoc, dispatchOffset, 0, 0},
{maxInvoc, dispatchOffset & 0xffffffffU, 0, 0},
};
ObjDisp(cmd)->CmdPushConstants(Unwrap(cmd), Unwrap(m_BufferMSPipeLayout),
@@ -168,7 +172,13 @@ void VulkanDebugManager::CopyTex2DMSToBuffer(VkCommandBuffer cmd, VkBuffer destB
ObjDisp(cmd)->CmdDispatch(Unwrap(cmd), numWorkGroup, 1, 1);
dispatchOffset += dispatchBufferSize / 4;
if(dispatchOffset > 0xffffffffULL)
break;
}
if(dispatchOffset > 0xffffffffULL)
break;
}
}
@@ -312,8 +322,12 @@ void VulkanDebugManager::CopyDepthTex2DMSToBuffer(VkCommandBuffer cmd, VkBuffer
}
}
const uint32_t dispatchBufferSize = GetByteSize(extent.width, extent.height, extent.depth, fmt, 0);
uint32_t dispatchOffset = 0;
const uint64_t dispatchBufferSize = GetByteSize(extent.width, extent.height, extent.depth, fmt, 0);
uint64_t dispatchOffset = 0;
RDCASSERTMSG("More than 32-bit offset required for CopyTex2DMSToBuffer",
uint64_t(numSlices) * uint64_t(numSamples) * dispatchBufferSize < 0xffffffffULL,
numSlices, numSamples, extent, fmt);
VkDescriptorBufferInfo destdesc = {0};
destdesc.buffer = destBuffer;
@@ -352,7 +366,7 @@ void VulkanDebugManager::CopyDepthTex2DMSToBuffer(VkCommandBuffer cmd, VkBuffer
Vec4u params[2] = {
{extent.width, currentSlice, currentSample, fmtIndex},
{maxInvoc, dispatchOffset, 0, 0},
{maxInvoc, dispatchOffset & 0xffffffffU, 0, 0},
};
ObjDisp(cmd)->CmdPushConstants(Unwrap(cmd), Unwrap(m_BufferMSPipeLayout), VK_SHADER_STAGE_ALL,
@@ -361,7 +375,13 @@ void VulkanDebugManager::CopyDepthTex2DMSToBuffer(VkCommandBuffer cmd, VkBuffer
ObjDisp(cmd)->CmdDispatch(Unwrap(cmd), numWorkGroup, 1, 1);
dispatchOffset += dispatchBufferSize / 4;
if(dispatchOffset > 0xffffffffULL)
break;
}
if(dispatchOffset > 0xffffffffULL)
break;
}
if(endCommand)
@@ -417,7 +437,7 @@ void VulkanDebugManager::CopyBufferToTex2DMS(VkCommandBuffer cmd, VkImage destMS
},
};
uint32_t bs = GetByteSize(1, 1, 1, fmt, 0);
uint32_t bs = (uint32_t)GetByteSize(1, 1, 1, fmt, 0);
if(bs == 1)
viewInfo.format = VK_FORMAT_R8_UINT;
@@ -464,9 +484,13 @@ void VulkanDebugManager::CopyBufferToTex2DMS(VkCommandBuffer cmd, VkImage destMS
ObjDisp(cmd)->CmdBindPipeline(Unwrap(cmd), VK_PIPELINE_BIND_POINT_COMPUTE,
Unwrap(m_Buffer2MSPipe));
const uint32_t dispatchBufferSize =
const uint64_t dispatchBufferSize =
GetByteSize(extent.width, extent.height, extent.depth, fmt, 0);
uint32_t dispatchOffset = 0;
uint64_t dispatchOffset = 0;
RDCASSERTMSG("More than 32-bit offset required for CopyTex2DMSToBuffer",
uint64_t(numSlices) * uint64_t(numSamples) * dispatchBufferSize < 0xffffffffULL,
numSlices, numSamples, extent, fmt);
VkDescriptorBufferInfo srcdesc = {0};
srcdesc.buffer = srcBuffer;
@@ -504,7 +528,7 @@ void VulkanDebugManager::CopyBufferToTex2DMS(VkCommandBuffer cmd, VkImage destMS
Vec4u params[2] = {
{extent.width, currentSlice, currentSample, bs},
{maxInvoc, dispatchOffset, 0, 0},
{maxInvoc, dispatchOffset & 0xffffffffU, 0, 0},
};
ObjDisp(cmd)->CmdPushConstants(Unwrap(cmd), Unwrap(m_BufferMSPipeLayout),
@@ -513,7 +537,13 @@ void VulkanDebugManager::CopyBufferToTex2DMS(VkCommandBuffer cmd, VkImage destMS
ObjDisp(cmd)->CmdDispatch(Unwrap(cmd), numWorkGroup, 1, 1);
dispatchOffset += dispatchBufferSize / 4;
if(dispatchOffset > 0xffffffffULL)
break;
}
if(dispatchOffset > 0xffffffffULL)
break;
}
}
+1 -1
View File
@@ -1243,7 +1243,7 @@ protected:
else
{
viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
uint32_t bs = GetByteSize(1, 1, 1, format, 0);
uint32_t bs = (uint32_t)GetByteSize(1, 1, 1, format, 0);
if(bs == 1)
viewInfo.format = VK_FORMAT_R8_UINT;
+2 -2
View File
@@ -4953,8 +4953,8 @@ void VulkanReplay::FetchVSOut(uint32_t eventId, VulkanRenderState &state)
else if(IsSIntFormat(origFormat))
expandedFormat = VK_FORMAT_R32G32B32A32_SINT;
uint32_t origElemSize = GetByteSize(1, 1, 1, origFormat, 0);
uint32_t elemSize = GetByteSize(1, 1, 1, expandedFormat, 0);
uint32_t origElemSize = (uint32_t)GetByteSize(1, 1, 1, origFormat, 0);
uint32_t elemSize = (uint32_t)GetByteSize(1, 1, 1, expandedFormat, 0);
// 64-bit values are packed as uvec2
if(Is64BitFormat(origFormat))
+4 -2
View File
@@ -126,7 +126,8 @@ VKMeshDisplayPipelines VulkanDebugManager::CacheMeshDisplayPipelines(VkPipelineL
// since we don't want to put the whole offset into the cache key we just put a single bit of
// 'offset bigger than stride padding'
uint32_t primaryStridePadding = primary.vertexByteStride - GetByteSize(1, 1, 1, primaryFmt, 0);
uint32_t primaryStridePadding =
primary.vertexByteStride - (uint32_t)GetByteSize(1, 1, 1, primaryFmt, 0);
if(primary.vertexByteOffset > primaryStridePadding)
key |= 1ULL << bit;
@@ -136,7 +137,8 @@ VKMeshDisplayPipelines VulkanDebugManager::CacheMeshDisplayPipelines(VkPipelineL
if(secondary.vertexResourceId != ResourceId())
{
secondaryStridePadding = secondary.vertexByteStride - GetByteSize(1, 1, 1, secondaryFmt, 0);
secondaryStridePadding =
secondary.vertexByteStride - (uint32_t)GetByteSize(1, 1, 1, secondaryFmt, 0);
if(secondary.vertexByteOffset > secondaryStridePadding)
key |= 1ULL << bit;
+9 -9
View File
@@ -3763,7 +3763,7 @@ void VulkanReplay::GetTextureData(ResourceId tex, const Subresource &sub,
VkResult vkr = vt->BeginCommandBuffer(Unwrap(cmd), &beginInfo);
CheckVkResult(vkr);
uint32_t dataSize = 0;
size_t dataSize = 0;
VkBuffer readbackBuf = VK_NULL_HANDLE;
VkDeviceMemory readbackMem = VK_NULL_HANDLE;
@@ -4188,15 +4188,15 @@ void VulkanReplay::GetTextureData(ResourceId tex, const Subresource &sub,
}
else if(wasms)
{
dataSize = GetByteSize(imInfo.extent.width, imInfo.extent.height, imInfo.extent.depth,
imCreateInfo.format, s.mip);
dataSize = (size_t)GetByteSize(imInfo.extent.width, imInfo.extent.height, imInfo.extent.depth,
imCreateInfo.format, s.mip);
// buffer size needs to be align to the int for shader writing
VkBufferCreateInfo bufInfo = {
VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
NULL,
0,
AlignUp(dataSize, 4U),
AlignUp(dataSize, (size_t)4U),
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
VK_BUFFER_USAGE_TRANSFER_DST_BIT,
};
@@ -4339,16 +4339,16 @@ void VulkanReplay::GetTextureData(ResourceId tex, const Subresource &sub,
copyregions.push_back(copyRegionTemplate);
}
dataSize = GetByteSize(imInfo.extent.width, imInfo.extent.height, imInfo.extent.depth,
imCreateInfo.format, s.mip);
dataSize = (size_t)GetByteSize(imInfo.extent.width, imInfo.extent.height, imInfo.extent.depth,
imCreateInfo.format, s.mip);
if(imCreateInfo.format == VK_FORMAT_D24_UNORM_S8_UINT)
{
// for most combined depth-stencil images this will be large enough for both to be copied
// separately, but for D24S8 we need to add extra space since they won't be copied packed
dataSize = AlignUp(dataSize, 4U);
dataSize += GetByteSize(imInfo.extent.width, imInfo.extent.height, imInfo.extent.depth,
VK_FORMAT_S8_UINT, s.mip);
dataSize = AlignUp(dataSize, (size_t)4U);
dataSize += (size_t)GetByteSize(imInfo.extent.width, imInfo.extent.height,
imInfo.extent.depth, VK_FORMAT_S8_UINT, s.mip);
}
VkBufferCreateInfo bufInfo = {
+7 -7
View File
@@ -1752,7 +1752,7 @@ VkExtent2D GetPlaneShape(uint32_t Width, uint32_t Height, VkFormat Format, uint3
}
}
uint32_t GetPlaneByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat Format,
uint64_t GetPlaneByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat Format,
uint32_t mip, uint32_t plane)
{
uint32_t mipWidth = RDCMAX(Width >> mip, 1U);
@@ -1763,16 +1763,16 @@ uint32_t GetPlaneByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFor
BlockShape blockShape = GetBlockShape(Format, plane);
uint32_t widthInBlocks = (planeShape.width + blockShape.width - 1) / blockShape.width;
uint32_t heightInBlocks = (planeShape.height + blockShape.height - 1) / blockShape.height;
uint64_t widthInBlocks = (planeShape.width + blockShape.width - 1) / blockShape.width;
uint64_t heightInBlocks = (planeShape.height + blockShape.height - 1) / blockShape.height;
return blockShape.bytes * widthInBlocks * heightInBlocks * mipDepth;
return uint64_t(blockShape.bytes) * widthInBlocks * heightInBlocks * uint64_t(mipDepth);
}
uint32_t GetByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat Format, uint32_t mip)
uint64_t GetByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat Format, uint32_t mip)
{
uint32_t planeCount = GetYUVPlaneCount(Format);
uint32_t size = 0;
uint64_t size = 0;
for(uint32_t p = 0; p < planeCount; p++)
size += GetPlaneByteSize(Width, Height, Depth, Format, mip, p);
return size;
@@ -4869,7 +4869,7 @@ TEST_CASE("Vulkan formats", "[format][vulkan]")
uint32_t planeCount = GetYUVPlaneCount(f);
uint32_t planeSum = 0;
uint64_t planeSum = 0;
for(uint32_t p = 0; p < planeCount; p++)
planeSum += GetPlaneByteSize(width, height, 1, f, 0, p);
+2 -2
View File
@@ -2471,8 +2471,8 @@ struct BlockShape
BlockShape GetBlockShape(VkFormat Format, uint32_t plane);
VkExtent2D GetPlaneShape(uint32_t Width, uint32_t Height, VkFormat Format, uint32_t plane);
uint32_t GetByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat Format, uint32_t mip);
uint32_t GetPlaneByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat Format,
uint64_t GetByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat Format, uint32_t mip);
uint64_t GetPlaneByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat Format,
uint32_t mip, uint32_t plane);
template <typename T>
+4 -3
View File
@@ -1508,7 +1508,8 @@ private:
struct ImageData
{
uint32_t width = 0, height = 0, depth = 0;
uint32_t texelSize = 0, rowPitch = 0, slicePitch = 0, samplePitch = 0;
uint32_t texelSize = 0;
uint64_t rowPitch = 0, slicePitch = 0, samplePitch = 0;
ResourceFormat fmt;
bytebuf bytes;
@@ -1725,8 +1726,8 @@ private:
ResourceFormat fmt = MakeResourceFormat(imageProps.format);
data.fmt = MakeResourceFormat(imageProps.format);
data.texelSize = GetByteSize(1, 1, 1, imageProps.format, 0);
data.rowPitch = GetByteSize(data.width, 1, 1, imageProps.format, 0);
data.texelSize = (uint32_t)GetByteSize(1, 1, 1, imageProps.format, 0);
data.rowPitch = (uint32_t)GetByteSize(data.width, 1, 1, imageProps.format, 0);
data.slicePitch = GetByteSize(data.width, data.height, 1, imageProps.format, 0);
data.samplePitch = GetByteSize(data.width, data.height, data.depth, imageProps.format, 0);
@@ -462,7 +462,7 @@ void WrappedVulkan::vkGetDeviceImageMemoryRequirements(VkDevice device,
if(formatListInfo)
{
uint32_t bs = GetByteSize(1, 1, 1, info->format, 0);
uint32_t bs = (uint32_t)GetByteSize(1, 1, 1, info->format, 0);
VkFormat msaaCopyFormat = VK_FORMAT_UNDEFINED;
if(bs == 1)
@@ -2203,7 +2203,7 @@ bool WrappedVulkan::Serialise_vkCreateImage(SerialiserType &ser, VkDevice device
if(formatListInfo)
{
uint32_t bs = GetByteSize(1, 1, 1, CreateInfo.format, 0);
uint32_t bs = (uint32_t)GetByteSize(1, 1, 1, CreateInfo.format, 0);
VkFormat msaaCopyFormat = VK_FORMAT_UNDEFINED;
if(bs == 1)
@@ -2430,7 +2430,7 @@ VkResult WrappedVulkan::vkCreateImage(VkDevice device, const VkImageCreateInfo *
if(formatListInfo)
{
uint32_t bs = GetByteSize(1, 1, 1, createInfo_adjusted.format, 0);
uint32_t bs = (uint32_t)GetByteSize(1, 1, 1, createInfo_adjusted.format, 0);
VkFormat msaaCopyFormat = VK_FORMAT_UNDEFINED;
if(bs == 1)