mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[d3d11] Store packed format info in D3D11CommonTexture
This commit is contained in:
parent
f155b8a8b9
commit
9e15831a2d
@ -14,6 +14,8 @@ namespace dxvk {
|
|||||||
DXGI_VK_FORMAT_MODE formatMode = GetFormatMode();
|
DXGI_VK_FORMAT_MODE formatMode = GetFormatMode();
|
||||||
DXGI_VK_FORMAT_INFO formatInfo = m_device->LookupFormat(m_desc.Format, formatMode);
|
DXGI_VK_FORMAT_INFO formatInfo = m_device->LookupFormat(m_desc.Format, formatMode);
|
||||||
DXGI_VK_FORMAT_FAMILY formatFamily = m_device->LookupFamily(m_desc.Format, formatMode);
|
DXGI_VK_FORMAT_FAMILY formatFamily = m_device->LookupFamily(m_desc.Format, formatMode);
|
||||||
|
DXGI_VK_FORMAT_INFO formatPacked = m_device->LookupPackedFormat(m_desc.Format, formatMode);
|
||||||
|
m_packedFormat = formatPacked.Format;
|
||||||
|
|
||||||
DxvkImageCreateInfo imageInfo;
|
DxvkImageCreateInfo imageInfo;
|
||||||
imageInfo.type = GetImageTypeFromResourceDim(Dimension);
|
imageInfo.type = GetImageTypeFromResourceDim(Dimension);
|
||||||
@ -246,7 +248,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
case D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER:
|
case D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER:
|
||||||
case D3D11_COMMON_TEXTURE_MAP_MODE_STAGING: {
|
case D3D11_COMMON_TEXTURE_MAP_MODE_STAGING: {
|
||||||
auto formatInfo = imageFormatInfo(m_device->LookupPackedFormat(m_desc.Format, GetFormatMode()).Format);
|
|
||||||
auto aspects = Aspect;
|
auto aspects = Aspect;
|
||||||
|
|
||||||
// The exact aspect mask only matters for multi-plane formats,
|
// The exact aspect mask only matters for multi-plane formats,
|
||||||
@ -257,18 +258,20 @@ namespace dxvk {
|
|||||||
VkExtent3D mipExtent = MipLevelExtent(subresource.mipLevel);
|
VkExtent3D mipExtent = MipLevelExtent(subresource.mipLevel);
|
||||||
|
|
||||||
while (aspects) {
|
while (aspects) {
|
||||||
|
auto packedFormatInfo = imageFormatInfo(m_packedFormat);
|
||||||
|
|
||||||
auto aspect = vk::getNextAspect(aspects);
|
auto aspect = vk::getNextAspect(aspects);
|
||||||
auto extent = mipExtent;
|
auto extent = mipExtent;
|
||||||
auto elementSize = formatInfo->elementSize;
|
auto elementSize = packedFormatInfo->elementSize;
|
||||||
|
|
||||||
if (formatInfo->flags.test(DxvkFormatFlag::MultiPlane)) {
|
if (packedFormatInfo->flags.test(DxvkFormatFlag::MultiPlane)) {
|
||||||
auto plane = &formatInfo->planes[vk::getPlaneIndex(aspect)];
|
auto plane = &packedFormatInfo->planes[vk::getPlaneIndex(aspect)];
|
||||||
extent.width /= plane->blockSize.width;
|
extent.width /= plane->blockSize.width;
|
||||||
extent.height /= plane->blockSize.height;
|
extent.height /= plane->blockSize.height;
|
||||||
elementSize = plane->elementSize;
|
elementSize = plane->elementSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto blockCount = util::computeBlockCount(extent, formatInfo->blockSize);
|
auto blockCount = util::computeBlockCount(extent, packedFormatInfo->blockSize);
|
||||||
|
|
||||||
if (!layout.RowPitch) {
|
if (!layout.RowPitch) {
|
||||||
layout.RowPitch = elementSize * blockCount.width;
|
layout.RowPitch = elementSize * blockCount.width;
|
||||||
|
@ -199,6 +199,18 @@ namespace dxvk {
|
|||||||
? m_buffers[Subresource].slice
|
? m_buffers[Subresource].slice
|
||||||
: DxvkBufferSliceHandle();
|
: DxvkBufferSliceHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns underlying packed Vulkan format
|
||||||
|
*
|
||||||
|
* This works even for staging resources that have no image.
|
||||||
|
* Note that for depth-stencil resources, the returned format
|
||||||
|
* may be different from the image format on some systems.
|
||||||
|
* \returns Packed Vulkan format
|
||||||
|
*/
|
||||||
|
VkFormat GetPackedFormat() const {
|
||||||
|
return m_packedFormat;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Checks whether we can update the mapped buffer early
|
* \brief Checks whether we can update the mapped buffer early
|
||||||
@ -296,6 +308,7 @@ namespace dxvk {
|
|||||||
D3D11_COMMON_TEXTURE_DESC m_desc;
|
D3D11_COMMON_TEXTURE_DESC m_desc;
|
||||||
D3D11_COMMON_TEXTURE_MAP_MODE m_mapMode;
|
D3D11_COMMON_TEXTURE_MAP_MODE m_mapMode;
|
||||||
DXGI_USAGE m_dxgiUsage;
|
DXGI_USAGE m_dxgiUsage;
|
||||||
|
VkFormat m_packedFormat;
|
||||||
|
|
||||||
Rc<DxvkImage> m_image;
|
Rc<DxvkImage> m_image;
|
||||||
std::vector<MappedBuffer> m_buffers;
|
std::vector<MappedBuffer> m_buffers;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user