mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[d3d11] Refactoring texture classes: Remove D3D11TextureInfo
This commit is contained in:
parent
16d66c8a1d
commit
56df0bcccb
@ -317,14 +317,17 @@ namespace dxvk {
|
|||||||
cSrcSlice.length());
|
cSrcSlice.length());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource);
|
const D3D11CommonTexture* dstTextureInfo = GetCommonTexture(pDstResource);
|
||||||
const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource);
|
const D3D11CommonTexture* srcTextureInfo = GetCommonTexture(pSrcResource);
|
||||||
|
|
||||||
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstTextureInfo->image->info().format);
|
const Rc<DxvkImage> dstImage = dstTextureInfo->GetImage();
|
||||||
const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcTextureInfo->image->info().format);
|
const Rc<DxvkImage> srcImage = srcTextureInfo->GetImage();
|
||||||
|
|
||||||
const VkImageSubresource dstSubresource = GetSubresourceFromIndex(dstFormatInfo->aspectMask, dstTextureInfo->image->info().mipLevels, DstSubresource);
|
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstImage->info().format);
|
||||||
const VkImageSubresource srcSubresource = GetSubresourceFromIndex(srcFormatInfo->aspectMask, srcTextureInfo->image->info().mipLevels, SrcSubresource);
|
const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcImage->info().format);
|
||||||
|
|
||||||
|
const VkImageSubresource dstSubresource = dstTextureInfo->GetSubresourceFromIndex(dstFormatInfo->aspectMask, DstSubresource);
|
||||||
|
const VkImageSubresource srcSubresource = srcTextureInfo->GetSubresourceFromIndex(srcFormatInfo->aspectMask, SrcSubresource);
|
||||||
|
|
||||||
VkOffset3D srcOffset = { 0, 0, 0 };
|
VkOffset3D srcOffset = { 0, 0, 0 };
|
||||||
VkOffset3D dstOffset = {
|
VkOffset3D dstOffset = {
|
||||||
@ -332,7 +335,7 @@ namespace dxvk {
|
|||||||
static_cast<int32_t>(DstY),
|
static_cast<int32_t>(DstY),
|
||||||
static_cast<int32_t>(DstZ) };
|
static_cast<int32_t>(DstZ) };
|
||||||
|
|
||||||
VkExtent3D extent = srcTextureInfo->image->mipLevelExtent(srcSubresource.mipLevel);
|
VkExtent3D extent = srcImage->mipLevelExtent(srcSubresource.mipLevel);
|
||||||
|
|
||||||
if (pSrcBox != nullptr) {
|
if (pSrcBox != nullptr) {
|
||||||
if (pSrcBox->left >= pSrcBox->right
|
if (pSrcBox->left >= pSrcBox->right
|
||||||
@ -360,8 +363,8 @@ namespace dxvk {
|
|||||||
srcSubresource.arrayLayer, 1 };
|
srcSubresource.arrayLayer, 1 };
|
||||||
|
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cDstImage = dstTextureInfo->image,
|
cDstImage = dstImage,
|
||||||
cSrcImage = srcTextureInfo->image,
|
cSrcImage = srcImage,
|
||||||
cDstLayers = dstLayers,
|
cDstLayers = dstLayers,
|
||||||
cSrcLayers = srcLayers,
|
cSrcLayers = srcLayers,
|
||||||
cDstOffset = dstOffset,
|
cDstOffset = dstOffset,
|
||||||
@ -412,21 +415,21 @@ namespace dxvk {
|
|||||||
cSrcBuffer.length());
|
cSrcBuffer.length());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource);
|
const Rc<DxvkImage> dstImage = GetCommonTexture(pDstResource)->GetImage();
|
||||||
const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource);
|
const Rc<DxvkImage> srcImage = GetCommonTexture(pSrcResource)->GetImage();
|
||||||
|
|
||||||
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstTextureInfo->image->info().format);
|
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstImage->info().format);
|
||||||
const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcTextureInfo->image->info().format);
|
const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcImage->info().format);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < srcImage->info().mipLevels; i++) {
|
||||||
|
VkExtent3D extent = srcImage->mipLevelExtent(i);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < srcTextureInfo->image->info().mipLevels; i++) {
|
const VkImageSubresourceLayers dstLayers = { dstFormatInfo->aspectMask, i, 0, dstImage->info().numLayers };
|
||||||
VkExtent3D extent = srcTextureInfo->image->mipLevelExtent(i);
|
const VkImageSubresourceLayers srcLayers = { srcFormatInfo->aspectMask, i, 0, srcImage->info().numLayers };
|
||||||
|
|
||||||
const VkImageSubresourceLayers dstLayers = { dstFormatInfo->aspectMask, i, 0, dstTextureInfo->image->info().numLayers };
|
|
||||||
const VkImageSubresourceLayers srcLayers = { srcFormatInfo->aspectMask, i, 0, srcTextureInfo->image->info().numLayers };
|
|
||||||
|
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cDstImage = dstTextureInfo->image,
|
cDstImage = dstImage,
|
||||||
cSrcImage = srcTextureInfo->image,
|
cSrcImage = srcImage,
|
||||||
cDstLayers = dstLayers,
|
cDstLayers = dstLayers,
|
||||||
cSrcLayers = srcLayers,
|
cSrcLayers = srcLayers,
|
||||||
cExtent = extent
|
cExtent = extent
|
||||||
@ -723,15 +726,14 @@ namespace dxvk {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const D3D11TextureInfo* textureInfo
|
const D3D11CommonTexture* textureInfo = GetCommonTexture(pDstResource);
|
||||||
= GetCommonTextureInfo(pDstResource);
|
|
||||||
|
|
||||||
const VkImageSubresource subresource =
|
const VkImageSubresource subresource =
|
||||||
GetSubresourceFromIndex(VK_IMAGE_ASPECT_COLOR_BIT,
|
textureInfo->GetSubresourceFromIndex(
|
||||||
textureInfo->image->info().mipLevels, DstSubresource);
|
VK_IMAGE_ASPECT_COLOR_BIT, DstSubresource);
|
||||||
|
|
||||||
VkOffset3D offset = { 0, 0, 0 };
|
VkOffset3D offset = { 0, 0, 0 };
|
||||||
VkExtent3D extent = textureInfo->image->mipLevelExtent(subresource.mipLevel);
|
VkExtent3D extent = textureInfo->GetImage()->mipLevelExtent(subresource.mipLevel);
|
||||||
|
|
||||||
if (pDstBox != nullptr) {
|
if (pDstBox != nullptr) {
|
||||||
if (pDstBox->left >= pDstBox->right
|
if (pDstBox->left >= pDstBox->right
|
||||||
@ -754,7 +756,7 @@ namespace dxvk {
|
|||||||
subresource.arrayLayer, 1 };
|
subresource.arrayLayer, 1 };
|
||||||
|
|
||||||
auto formatInfo = imageFormatInfo(
|
auto formatInfo = imageFormatInfo(
|
||||||
textureInfo->image->info().format);
|
textureInfo->GetImage()->info().format);
|
||||||
|
|
||||||
const VkExtent3D regionExtent = util::computeBlockCount(extent, formatInfo->blockSize);
|
const VkExtent3D regionExtent = util::computeBlockCount(extent, formatInfo->blockSize);
|
||||||
|
|
||||||
@ -771,7 +773,7 @@ namespace dxvk {
|
|||||||
SrcRowPitch, SrcDepthPitch);
|
SrcRowPitch, SrcDepthPitch);
|
||||||
|
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cDstImage = textureInfo->image,
|
cDstImage = textureInfo->GetImage(),
|
||||||
cDstLayers = layers,
|
cDstLayers = layers,
|
||||||
cDstOffset = offset,
|
cDstOffset = offset,
|
||||||
cDstExtent = extent,
|
cDstExtent = extent,
|
||||||
@ -832,19 +834,19 @@ namespace dxvk {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource);
|
const D3D11CommonTexture* dstTextureInfo = GetCommonTexture(pDstResource);
|
||||||
const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource);
|
const D3D11CommonTexture* srcTextureInfo = GetCommonTexture(pSrcResource);
|
||||||
|
|
||||||
const DxgiFormatInfo dstFormatInfo = m_parent->LookupFormat(dstDesc.Format, DxgiFormatMode::Any);
|
const DxgiFormatInfo dstFormatInfo = m_parent->LookupFormat(dstDesc.Format, DxgiFormatMode::Any);
|
||||||
const DxgiFormatInfo srcFormatInfo = m_parent->LookupFormat(srcDesc.Format, DxgiFormatMode::Any);
|
const DxgiFormatInfo srcFormatInfo = m_parent->LookupFormat(srcDesc.Format, DxgiFormatMode::Any);
|
||||||
|
|
||||||
const VkImageSubresource dstSubresource =
|
const VkImageSubresource dstSubresource =
|
||||||
GetSubresourceFromIndex(dstFormatInfo.aspect,
|
dstTextureInfo->GetSubresourceFromIndex(
|
||||||
dstTextureInfo->image->info().mipLevels, DstSubresource);
|
dstFormatInfo.aspect, DstSubresource);
|
||||||
|
|
||||||
const VkImageSubresource srcSubresource =
|
const VkImageSubresource srcSubresource =
|
||||||
GetSubresourceFromIndex(srcFormatInfo.aspect,
|
srcTextureInfo->GetSubresourceFromIndex(
|
||||||
srcTextureInfo->image->info().mipLevels, SrcSubresource);
|
srcFormatInfo.aspect, SrcSubresource);
|
||||||
|
|
||||||
const VkImageSubresourceLayers dstSubresourceLayers = {
|
const VkImageSubresourceLayers dstSubresourceLayers = {
|
||||||
dstSubresource.aspectMask,
|
dstSubresource.aspectMask,
|
||||||
@ -858,8 +860,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (srcDesc.SampleDesc.Count == 1) {
|
if (srcDesc.SampleDesc.Count == 1) {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cDstImage = dstTextureInfo->image,
|
cDstImage = dstTextureInfo->GetImage(),
|
||||||
cSrcImage = srcTextureInfo->image,
|
cSrcImage = srcTextureInfo->GetImage(),
|
||||||
cDstLayers = dstSubresourceLayers,
|
cDstLayers = dstSubresourceLayers,
|
||||||
cSrcLayers = srcSubresourceLayers
|
cSrcLayers = srcSubresourceLayers
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
@ -873,8 +875,8 @@ namespace dxvk {
|
|||||||
Format, DxgiFormatMode::Any).format;
|
Format, DxgiFormatMode::Any).format;
|
||||||
|
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cDstImage = dstTextureInfo->image,
|
cDstImage = dstTextureInfo->GetImage(),
|
||||||
cSrcImage = srcTextureInfo->image,
|
cSrcImage = srcTextureInfo->GetImage(),
|
||||||
cDstSubres = dstSubresourceLayers,
|
cDstSubres = dstSubresourceLayers,
|
||||||
cSrcSubres = srcSubresourceLayers,
|
cSrcSubres = srcSubresourceLayers,
|
||||||
cFormat = format
|
cFormat = format
|
||||||
|
@ -143,103 +143,83 @@ namespace dxvk {
|
|||||||
pMappedResource->DepthPitch = physicalSlice.length();
|
pMappedResource->DepthPitch = physicalSlice.length();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} else {
|
} else {
|
||||||
// Depending on whether the image has been allocated on a
|
D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
// host-visible memory type, we can either use the mapped
|
|
||||||
// memory region directly, or we map a linear buffer.
|
|
||||||
D3D11TextureInfo* textureInfo = GetCommonTextureInfo(pResource);
|
|
||||||
const DxvkImageCreateInfo& imageInfo = textureInfo->image->info();
|
|
||||||
|
|
||||||
textureInfo->mappedSubresource = GetSubresourceFromIndex(
|
const Rc<DxvkImage> mappedImage = textureInfo->GetImage();
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT, imageInfo.mipLevels, Subresource);
|
const Rc<DxvkBuffer> mappedBuffer = textureInfo->GetMappedBuffer();
|
||||||
|
|
||||||
if (textureInfo->image->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
|
if (mappedBuffer == nullptr) {
|
||||||
const VkSubresourceLayout subresourceLayout =
|
Logger::err("D3D11: Cannot map a device-local image");
|
||||||
textureInfo->image->querySubresourceLayout(
|
return E_INVALIDARG;
|
||||||
textureInfo->mappedSubresource);
|
}
|
||||||
|
|
||||||
|
if (pMappedResource == nullptr)
|
||||||
|
return S_FALSE;
|
||||||
|
|
||||||
|
VkImageSubresource subresource =
|
||||||
|
textureInfo->GetSubresourceFromIndex(
|
||||||
|
VK_IMAGE_ASPECT_COLOR_BIT, Subresource);
|
||||||
|
|
||||||
|
textureInfo->SetMappedSubresource(subresource);
|
||||||
|
|
||||||
|
// Query format info in order to compute
|
||||||
|
// the row pitch and layer pitch properly.
|
||||||
|
const DxvkFormatInfo* formatInfo = imageFormatInfo(mappedImage->info().format);
|
||||||
|
|
||||||
|
const VkExtent3D levelExtent = mappedImage->mipLevelExtent(subresource.mipLevel);
|
||||||
|
const VkExtent3D blockCount = util::computeBlockCount(
|
||||||
|
levelExtent, formatInfo->blockSize);
|
||||||
|
|
||||||
|
DxvkPhysicalBufferSlice physicalSlice;
|
||||||
|
|
||||||
|
// When using any map mode which requires the image contents
|
||||||
|
// to be preserved, copy the image's contents into the buffer.
|
||||||
|
if (MapType == D3D11_MAP_WRITE_DISCARD) {
|
||||||
|
physicalSlice = mappedBuffer->allocPhysicalSlice();
|
||||||
|
physicalSlice.resource()->acquire();
|
||||||
|
|
||||||
if (!WaitForResource(textureInfo->image, MapFlags))
|
EmitCs([
|
||||||
return DXGI_ERROR_WAS_STILL_DRAWING;
|
cImageBuffer = mappedBuffer,
|
||||||
|
cPhysicalSlice = physicalSlice
|
||||||
pMappedResource->pData = textureInfo->image->mapPtr(subresourceLayout.offset);
|
] (DxvkContext* ctx) {
|
||||||
pMappedResource->RowPitch = subresourceLayout.rowPitch;
|
ctx->invalidateBuffer(cImageBuffer, cPhysicalSlice);
|
||||||
pMappedResource->DepthPitch = subresourceLayout.rowPitch * imageInfo.extent.height;
|
cPhysicalSlice.resource()->release();
|
||||||
|
});
|
||||||
if (imageInfo.type == VK_IMAGE_TYPE_3D)
|
|
||||||
pMappedResource->DepthPitch = subresourceLayout.depthPitch;
|
|
||||||
else if (imageInfo.numLayers > 1)
|
|
||||||
pMappedResource->DepthPitch = subresourceLayout.arrayPitch;
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
} else {
|
} else {
|
||||||
if (textureInfo->imageBuffer == nullptr) {
|
// We may have to copy the current image contents into the
|
||||||
Logger::err("D3D11: Cannot map a device-local image");
|
// mapped buffer if the GPU has write access to the image.
|
||||||
return E_INVALIDARG;
|
const bool copyExistingData = textureInfo->Desc()->Usage == D3D11_USAGE_STAGING;
|
||||||
}
|
|
||||||
|
|
||||||
if (pMappedResource == nullptr)
|
if (copyExistingData) {
|
||||||
return S_FALSE;
|
const VkImageSubresourceLayers subresourceLayers = {
|
||||||
|
subresource.aspectMask,
|
||||||
// Query format info in order to compute
|
subresource.mipLevel,
|
||||||
// the row pitch and layer pitch properly.
|
subresource.arrayLayer, 1 };
|
||||||
const DxvkFormatInfo* formatInfo = imageFormatInfo(imageInfo.format);
|
|
||||||
|
|
||||||
const VkExtent3D levelExtent = textureInfo->image
|
|
||||||
->mipLevelExtent(textureInfo->mappedSubresource.mipLevel);
|
|
||||||
|
|
||||||
const VkExtent3D blockCount = util::computeBlockCount(
|
|
||||||
levelExtent, formatInfo->blockSize);
|
|
||||||
|
|
||||||
DxvkPhysicalBufferSlice physicalSlice;
|
|
||||||
|
|
||||||
// When using any map mode which requires the image contents
|
|
||||||
// to be preserved, copy the image's contents into the buffer.
|
|
||||||
if (MapType == D3D11_MAP_WRITE_DISCARD) {
|
|
||||||
physicalSlice = textureInfo->imageBuffer->allocPhysicalSlice();
|
|
||||||
physicalSlice.resource()->acquire();
|
|
||||||
|
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cImageBuffer = textureInfo->imageBuffer,
|
cImageBuffer = mappedBuffer,
|
||||||
cPhysicalSlice = physicalSlice
|
cImage = mappedImage,
|
||||||
|
cSubresources = subresourceLayers,
|
||||||
|
cLevelExtent = levelExtent
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
ctx->invalidateBuffer(cImageBuffer, cPhysicalSlice);
|
ctx->copyImageToBuffer(
|
||||||
cPhysicalSlice.resource()->release();
|
cImageBuffer, 0, VkExtent2D { 0u, 0u },
|
||||||
|
cImage, cSubresources, VkOffset3D { 0, 0, 0 },
|
||||||
|
cLevelExtent);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
// We may have to copy the current image contents into the
|
|
||||||
// mapped buffer if the GPU has write access to the image.
|
|
||||||
const bool copyExistingData = textureInfo->usage == D3D11_USAGE_STAGING;
|
|
||||||
|
|
||||||
if (copyExistingData) {
|
|
||||||
const VkImageSubresourceLayers subresourceLayers = {
|
|
||||||
textureInfo->mappedSubresource.aspectMask,
|
|
||||||
textureInfo->mappedSubresource.mipLevel,
|
|
||||||
textureInfo->mappedSubresource.arrayLayer, 1 };
|
|
||||||
|
|
||||||
EmitCs([
|
|
||||||
cImageBuffer = textureInfo->imageBuffer,
|
|
||||||
cImage = textureInfo->image,
|
|
||||||
cSubresources = subresourceLayers,
|
|
||||||
cLevelExtent = levelExtent
|
|
||||||
] (DxvkContext* ctx) {
|
|
||||||
ctx->copyImageToBuffer(
|
|
||||||
cImageBuffer, 0, VkExtent2D { 0u, 0u },
|
|
||||||
cImage, cSubresources, VkOffset3D { 0, 0, 0 },
|
|
||||||
cLevelExtent);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!WaitForResource(textureInfo->imageBuffer->resource(), MapFlags))
|
|
||||||
return DXGI_ERROR_WAS_STILL_DRAWING;
|
|
||||||
|
|
||||||
physicalSlice = textureInfo->imageBuffer->slice();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up map pointer. Data is tightly packed within the mapped buffer.
|
if (!WaitForResource(mappedBuffer->resource(), MapFlags))
|
||||||
pMappedResource->pData = physicalSlice.mapPtr(0);
|
return DXGI_ERROR_WAS_STILL_DRAWING;
|
||||||
pMappedResource->RowPitch = formatInfo->elementSize * blockCount.width;
|
|
||||||
pMappedResource->DepthPitch = formatInfo->elementSize * blockCount.width * blockCount.height;
|
physicalSlice = mappedBuffer->slice();
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up map pointer. Data is tightly packed within the mapped buffer.
|
||||||
|
pMappedResource->pData = physicalSlice.mapPtr(0);
|
||||||
|
pMappedResource->RowPitch = formatInfo->elementSize * blockCount.width;
|
||||||
|
pMappedResource->DepthPitch = formatInfo->elementSize * blockCount.width * blockCount.height;
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,29 +233,31 @@ namespace dxvk {
|
|||||||
if (resourceDim != D3D11_RESOURCE_DIMENSION_BUFFER) {
|
if (resourceDim != D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||||
// Now that data has been written into the buffer,
|
// Now that data has been written into the buffer,
|
||||||
// we need to copy its contents into the image
|
// we need to copy its contents into the image
|
||||||
const D3D11TextureInfo* textureInfo
|
D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
= GetCommonTextureInfo(pResource);
|
|
||||||
|
|
||||||
if (!(textureInfo->image->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) {
|
const Rc<DxvkImage> mappedImage = textureInfo->GetImage();
|
||||||
const VkExtent3D levelExtent = textureInfo->image
|
const Rc<DxvkBuffer> mappedBuffer = textureInfo->GetMappedBuffer();
|
||||||
->mipLevelExtent(textureInfo->mappedSubresource.mipLevel);
|
|
||||||
|
VkImageSubresource subresource = textureInfo->GetMappedSubresource();
|
||||||
const VkImageSubresourceLayers subresourceLayers = {
|
|
||||||
textureInfo->mappedSubresource.aspectMask,
|
VkExtent3D levelExtent = mappedImage
|
||||||
textureInfo->mappedSubresource.mipLevel,
|
->mipLevelExtent(subresource.mipLevel);
|
||||||
textureInfo->mappedSubresource.arrayLayer, 1 };
|
|
||||||
|
VkImageSubresourceLayers subresourceLayers = {
|
||||||
EmitCs([
|
subresource.aspectMask,
|
||||||
cSrcBuffer = textureInfo->imageBuffer,
|
subresource.mipLevel,
|
||||||
cDstImage = textureInfo->image,
|
subresource.arrayLayer, 1 };
|
||||||
cDstLayers = subresourceLayers,
|
|
||||||
cDstLevelExtent = levelExtent
|
EmitCs([
|
||||||
] (DxvkContext* ctx) {
|
cSrcBuffer = mappedBuffer,
|
||||||
ctx->copyBufferToImage(cDstImage, cDstLayers,
|
cDstImage = mappedImage,
|
||||||
VkOffset3D { 0, 0, 0 }, cDstLevelExtent,
|
cDstLayers = subresourceLayers,
|
||||||
cSrcBuffer, 0, { 0u, 0u });
|
cDstLevelExtent = levelExtent
|
||||||
});
|
] (DxvkContext* ctx) {
|
||||||
}
|
ctx->copyBufferToImage(cDstImage, cDstLayers,
|
||||||
|
VkOffset3D { 0, 0, 0 }, cDstLevelExtent,
|
||||||
|
cSrcBuffer, 0, { 0u, 0u });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,10 +123,8 @@ namespace dxvk {
|
|||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const Com<D3D11Texture1D> texture
|
const Com<D3D11Texture1D> texture = new D3D11Texture1D(this, &desc);
|
||||||
= new D3D11Texture1D(this, &desc);
|
this->InitTexture(texture->GetCommonTexture()->GetImage(), pInitialData);
|
||||||
|
|
||||||
this->InitTexture(texture->GetTextureInfo()->image, pInitialData);
|
|
||||||
*ppTexture1D = texture.ref();
|
*ppTexture1D = texture.ref();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& e) {
|
} catch (const DxvkError& e) {
|
||||||
@ -160,10 +158,8 @@ namespace dxvk {
|
|||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const Com<D3D11Texture2D> texture
|
const Com<D3D11Texture2D> texture = new D3D11Texture2D(this, &desc);
|
||||||
= new D3D11Texture2D(this, &desc);
|
this->InitTexture(texture->GetCommonTexture()->GetImage(), pInitialData);
|
||||||
|
|
||||||
this->InitTexture(texture->GetTextureInfo()->image, pInitialData);
|
|
||||||
*ppTexture2D = texture.ref();
|
*ppTexture2D = texture.ref();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& e) {
|
} catch (const DxvkError& e) {
|
||||||
@ -197,10 +193,8 @@ namespace dxvk {
|
|||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const Com<D3D11Texture3D> texture
|
const Com<D3D11Texture3D> texture = new D3D11Texture3D(this, &desc);
|
||||||
= new D3D11Texture3D(this, &desc);
|
this->InitTexture(texture->GetCommonTexture()->GetImage(), pInitialData);
|
||||||
|
|
||||||
this->InitTexture(texture->GetTextureInfo()->image, pInitialData);
|
|
||||||
*ppTexture3D = texture.ref();
|
*ppTexture3D = texture.ref();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& e) {
|
} catch (const DxvkError& e) {
|
||||||
@ -299,11 +293,9 @@ namespace dxvk {
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Retrieve info about the image
|
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
const D3D11TextureInfo* textureInfo
|
|
||||||
= GetCommonTextureInfo(pResource);
|
|
||||||
|
|
||||||
if ((textureInfo->bindFlags & D3D11_BIND_SHADER_RESOURCE) == 0) {
|
if ((textureInfo->Desc()->BindFlags & D3D11_BIND_SHADER_RESOURCE) == 0) {
|
||||||
Logger::warn("D3D11: Trying to create SRV for texture without D3D11_BIND_SHADER_RESOURCE");
|
Logger::warn("D3D11: Trying to create SRV for texture without D3D11_BIND_SHADER_RESOURCE");
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
@ -312,7 +304,7 @@ namespace dxvk {
|
|||||||
// on the view dimension field in the view description,
|
// on the view dimension field in the view description,
|
||||||
// not on the resource type.
|
// not on the resource type.
|
||||||
const DxgiFormatInfo formatInfo = m_dxgiAdapter
|
const DxgiFormatInfo formatInfo = m_dxgiAdapter
|
||||||
->LookupFormat(desc.Format, textureInfo->formatMode);
|
->LookupFormat(desc.Format, textureInfo->GetFormatMode());
|
||||||
|
|
||||||
DxvkImageViewCreateInfo viewInfo;
|
DxvkImageViewCreateInfo viewInfo;
|
||||||
viewInfo.format = formatInfo.format;
|
viewInfo.format = formatInfo.format;
|
||||||
@ -406,7 +398,8 @@ namespace dxvk {
|
|||||||
*ppSRView = ref(new D3D11ShaderResourceView(
|
*ppSRView = ref(new D3D11ShaderResourceView(
|
||||||
this, pResource, desc,
|
this, pResource, desc,
|
||||||
m_dxvkDevice->createImageView(
|
m_dxvkDevice->createImageView(
|
||||||
textureInfo->image, viewInfo)));
|
textureInfo->GetImage(),
|
||||||
|
viewInfo)));
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& e) {
|
} catch (const DxvkError& e) {
|
||||||
Logger::err(e.message());
|
Logger::err(e.message());
|
||||||
@ -495,11 +488,9 @@ namespace dxvk {
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Retrieve info about the image
|
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
const D3D11TextureInfo* textureInfo
|
|
||||||
= GetCommonTextureInfo(pResource);
|
|
||||||
|
|
||||||
if ((textureInfo->bindFlags & D3D11_BIND_UNORDERED_ACCESS) == 0) {
|
if ((textureInfo->Desc()->BindFlags & D3D11_BIND_UNORDERED_ACCESS) == 0) {
|
||||||
Logger::warn("D3D11: Trying to create UAV for texture without D3D11_BIND_UNORDERED_ACCESS");
|
Logger::warn("D3D11: Trying to create UAV for texture without D3D11_BIND_UNORDERED_ACCESS");
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
@ -508,7 +499,7 @@ namespace dxvk {
|
|||||||
// on the view dimension field in the view description,
|
// on the view dimension field in the view description,
|
||||||
// not on the resource type.
|
// not on the resource type.
|
||||||
const DxgiFormatInfo formatInfo = m_dxgiAdapter
|
const DxgiFormatInfo formatInfo = m_dxgiAdapter
|
||||||
->LookupFormat(desc.Format, textureInfo->formatMode);
|
->LookupFormat(desc.Format, textureInfo->GetFormatMode());
|
||||||
|
|
||||||
DxvkImageViewCreateInfo viewInfo;
|
DxvkImageViewCreateInfo viewInfo;
|
||||||
viewInfo.format = formatInfo.format;
|
viewInfo.format = formatInfo.format;
|
||||||
@ -572,7 +563,8 @@ namespace dxvk {
|
|||||||
*ppUAView = ref(new D3D11UnorderedAccessView(
|
*ppUAView = ref(new D3D11UnorderedAccessView(
|
||||||
this, pResource, desc,
|
this, pResource, desc,
|
||||||
m_dxvkDevice->createImageView(
|
m_dxvkDevice->createImageView(
|
||||||
textureInfo->image, viewInfo),
|
textureInfo->GetImage(),
|
||||||
|
viewInfo),
|
||||||
DxvkBufferSlice()));
|
DxvkBufferSlice()));
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& e) {
|
} catch (const DxvkError& e) {
|
||||||
@ -606,10 +598,9 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the image that we are going to create the view for
|
// Retrieve the image that we are going to create the view for
|
||||||
const D3D11TextureInfo* textureInfo
|
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
= GetCommonTextureInfo(pResource);
|
|
||||||
|
|
||||||
if ((textureInfo->bindFlags & D3D11_BIND_RENDER_TARGET) == 0) {
|
if ((textureInfo->Desc()->BindFlags & D3D11_BIND_RENDER_TARGET) == 0) {
|
||||||
Logger::warn("D3D11: Trying to create RTV for texture without D3D11_BIND_RENDER_TARGET");
|
Logger::warn("D3D11: Trying to create RTV for texture without D3D11_BIND_RENDER_TARGET");
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
@ -691,7 +682,8 @@ namespace dxvk {
|
|||||||
*ppRTView = ref(new D3D11RenderTargetView(
|
*ppRTView = ref(new D3D11RenderTargetView(
|
||||||
this, pResource, desc,
|
this, pResource, desc,
|
||||||
m_dxvkDevice->createImageView(
|
m_dxvkDevice->createImageView(
|
||||||
textureInfo->image, viewInfo)));
|
textureInfo->GetImage(),
|
||||||
|
viewInfo)));
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& e) {
|
} catch (const DxvkError& e) {
|
||||||
Logger::err(e.message());
|
Logger::err(e.message());
|
||||||
@ -723,10 +715,9 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the image that we are going to create the view for
|
// Retrieve the image that we are going to create the view for
|
||||||
const D3D11TextureInfo* textureInfo
|
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
= GetCommonTextureInfo(pResource);
|
|
||||||
|
|
||||||
if ((textureInfo->bindFlags & D3D11_BIND_DEPTH_STENCIL) == 0) {
|
if ((textureInfo->Desc()->BindFlags & D3D11_BIND_DEPTH_STENCIL) == 0) {
|
||||||
Logger::warn("D3D11: Trying to create DSV for texture without D3D11_BIND_DEPTH_STENCIL");
|
Logger::warn("D3D11: Trying to create DSV for texture without D3D11_BIND_DEPTH_STENCIL");
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
@ -800,7 +791,8 @@ namespace dxvk {
|
|||||||
*ppDepthStencilView = ref(new D3D11DepthStencilView(
|
*ppDepthStencilView = ref(new D3D11DepthStencilView(
|
||||||
this, pResource, desc,
|
this, pResource, desc,
|
||||||
m_dxvkDevice->createImageView(
|
m_dxvkDevice->createImageView(
|
||||||
textureInfo->image, viewInfo)));
|
textureInfo->GetImage(),
|
||||||
|
viewInfo)));
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& e) {
|
} catch (const DxvkError& e) {
|
||||||
Logger::err(e.message());
|
Logger::err(e.message());
|
||||||
|
@ -10,7 +10,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
Rc<DxvkImage> D3D11PresentBackBuffer::GetDXVKImage() {
|
Rc<DxvkImage> D3D11PresentBackBuffer::GetDXVKImage() {
|
||||||
return m_texture->GetTextureInfo()->image;
|
return m_texture->GetCommonTexture()->GetImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,12 +180,6 @@ namespace dxvk {
|
|||||||
m_buffer = m_desc.CPUAccessFlags != 0
|
m_buffer = m_desc.CPUAccessFlags != 0
|
||||||
? CreateImageBuffer(m_device->GetDXVKDevice(), info.format, info.extent)
|
? CreateImageBuffer(m_device->GetDXVKDevice(), info.format, info.extent)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
m_texinfo.formatMode = GetFormatMode();
|
|
||||||
m_texinfo.imageBuffer = m_buffer;
|
|
||||||
m_texinfo.image = m_image;
|
|
||||||
m_texinfo.usage = m_desc.Usage;
|
|
||||||
m_texinfo.bindFlags = m_desc.BindFlags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -196,7 +190,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
VkImageSubresource D3D11CommonTexture::GetSubresourceFromIndex(
|
VkImageSubresource D3D11CommonTexture::GetSubresourceFromIndex(
|
||||||
VkImageAspectFlags Aspect,
|
VkImageAspectFlags Aspect,
|
||||||
UINT Subresource) {
|
UINT Subresource) const {
|
||||||
VkImageSubresource result;
|
VkImageSubresource result;
|
||||||
result.aspectMask = Aspect;
|
result.aspectMask = Aspect;
|
||||||
result.mipLevel = Subresource % m_desc.MipLevels;
|
result.mipLevel = Subresource % m_desc.MipLevels;
|
||||||
@ -426,35 +420,23 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
D3D11TextureInfo* GetCommonTextureInfo(ID3D11Resource* pResource) {
|
D3D11CommonTexture* GetCommonTexture(ID3D11Resource* pResource) {
|
||||||
D3D11_RESOURCE_DIMENSION dimension = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
D3D11_RESOURCE_DIMENSION dimension = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
||||||
pResource->GetType(&dimension);
|
pResource->GetType(&dimension);
|
||||||
|
|
||||||
switch (dimension) {
|
switch (dimension) {
|
||||||
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
|
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
|
||||||
return static_cast<D3D11Texture1D*>(pResource)->GetTextureInfo();
|
return static_cast<D3D11Texture1D*>(pResource)->GetCommonTexture();
|
||||||
|
|
||||||
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
|
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
|
||||||
return static_cast<D3D11Texture2D*>(pResource)->GetTextureInfo();
|
return static_cast<D3D11Texture2D*>(pResource)->GetCommonTexture();
|
||||||
|
|
||||||
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
|
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
|
||||||
return static_cast<D3D11Texture3D*>(pResource)->GetTextureInfo();
|
return static_cast<D3D11Texture3D*>(pResource)->GetCommonTexture();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkImageSubresource GetSubresourceFromIndex(
|
|
||||||
VkImageAspectFlags Aspect,
|
|
||||||
UINT MipLevels,
|
|
||||||
UINT Subresource) {
|
|
||||||
VkImageSubresource result;
|
|
||||||
result.aspectMask = Aspect;
|
|
||||||
result.mipLevel = Subresource % MipLevels;
|
|
||||||
result.arrayLayer = Subresource / MipLevels;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,25 +9,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
class D3D11Device;
|
class D3D11Device;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Common texture info
|
|
||||||
*
|
|
||||||
* Stores the image and the image format
|
|
||||||
* mode for a texture of any type.
|
|
||||||
*/
|
|
||||||
struct D3D11TextureInfo {
|
|
||||||
DxgiFormatMode formatMode;
|
|
||||||
Rc<DxvkBuffer> imageBuffer;
|
|
||||||
Rc<DxvkImage> image;
|
|
||||||
|
|
||||||
D3D11_USAGE usage;
|
|
||||||
UINT bindFlags;
|
|
||||||
|
|
||||||
VkImageSubresource mappedSubresource = {
|
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Common texture description
|
* \brief Common texture description
|
||||||
*
|
*
|
||||||
@ -78,19 +59,11 @@ namespace dxvk {
|
|||||||
return &m_desc;
|
return &m_desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Texture info
|
|
||||||
* \todo NUKE THIS
|
|
||||||
*/
|
|
||||||
D3D11TextureInfo* GetTextureInfo() {
|
|
||||||
return &m_texinfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The DXVK image
|
* \brief The DXVK image
|
||||||
* \returns The DXVK image
|
* \returns The DXVK image
|
||||||
*/
|
*/
|
||||||
Rc<DxvkImage> GetDxvkImage() const {
|
Rc<DxvkImage> GetImage() const {
|
||||||
return m_image;
|
return m_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +71,7 @@ namespace dxvk {
|
|||||||
* \brief The DXVK buffer
|
* \brief The DXVK buffer
|
||||||
* \returns The DXVK buffer
|
* \returns The DXVK buffer
|
||||||
*/
|
*/
|
||||||
Rc<DxvkBuffer> GetDxvkBuffer() const {
|
Rc<DxvkBuffer> GetMappedBuffer() const {
|
||||||
return m_buffer;
|
return m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +110,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
VkImageSubresource GetSubresourceFromIndex(
|
VkImageSubresource GetSubresourceFromIndex(
|
||||||
VkImageAspectFlags Aspect,
|
VkImageAspectFlags Aspect,
|
||||||
UINT Subresource);
|
UINT Subresource) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Format mode
|
* \brief Format mode
|
||||||
@ -177,9 +150,6 @@ namespace dxvk {
|
|||||||
VkImageSubresource m_mappedSubresource
|
VkImageSubresource m_mappedSubresource
|
||||||
= { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 };
|
= { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 };
|
||||||
|
|
||||||
// TODO get rid of this
|
|
||||||
D3D11TextureInfo m_texinfo;
|
|
||||||
|
|
||||||
static VkImageType GetImageTypeFromResourceDim(
|
static VkImageType GetImageTypeFromResourceDim(
|
||||||
D3D11_RESOURCE_DIMENSION Dimension);
|
D3D11_RESOURCE_DIMENSION Dimension);
|
||||||
|
|
||||||
@ -215,8 +185,8 @@ namespace dxvk {
|
|||||||
void STDMETHODCALLTYPE GetDesc(
|
void STDMETHODCALLTYPE GetDesc(
|
||||||
D3D11_TEXTURE1D_DESC *pDesc) final;
|
D3D11_TEXTURE1D_DESC *pDesc) final;
|
||||||
|
|
||||||
D3D11TextureInfo* GetTextureInfo() {
|
D3D11CommonTexture* GetCommonTexture() {
|
||||||
return m_texture.GetTextureInfo();
|
return &m_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -255,8 +225,8 @@ namespace dxvk {
|
|||||||
void STDMETHODCALLTYPE GetDesc(
|
void STDMETHODCALLTYPE GetDesc(
|
||||||
D3D11_TEXTURE2D_DESC *pDesc) final;
|
D3D11_TEXTURE2D_DESC *pDesc) final;
|
||||||
|
|
||||||
D3D11TextureInfo* GetTextureInfo() {
|
D3D11CommonTexture* GetCommonTexture() {
|
||||||
return m_texture.GetTextureInfo();
|
return &m_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -295,8 +265,8 @@ namespace dxvk {
|
|||||||
void STDMETHODCALLTYPE GetDesc(
|
void STDMETHODCALLTYPE GetDesc(
|
||||||
D3D11_TEXTURE3D_DESC *pDesc) final;
|
D3D11_TEXTURE3D_DESC *pDesc) final;
|
||||||
|
|
||||||
D3D11TextureInfo* GetTextureInfo() {
|
D3D11CommonTexture* GetCommonTexture() {
|
||||||
return m_texture.GetTextureInfo();
|
return &m_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -313,20 +283,7 @@ namespace dxvk {
|
|||||||
* \param [out] pTextureInfo Pointer to the texture info struct.
|
* \param [out] pTextureInfo Pointer to the texture info struct.
|
||||||
* \returns E_INVALIDARG if the resource is not a texture
|
* \returns E_INVALIDARG if the resource is not a texture
|
||||||
*/
|
*/
|
||||||
D3D11TextureInfo* GetCommonTextureInfo(
|
D3D11CommonTexture* GetCommonTexture(
|
||||||
ID3D11Resource* pResource);
|
ID3D11Resource* pResource);
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Computes image subresource from subresource index
|
|
||||||
*
|
|
||||||
* \param [in] Aspect Image aspect mask
|
|
||||||
* \param [in] MipLevels Total number of mip levels that the image has
|
|
||||||
* \param [in] Subresource The D3D11 subresource index
|
|
||||||
* \returns Vulkan image subresource info
|
|
||||||
*/
|
|
||||||
VkImageSubresource GetSubresourceFromIndex(
|
|
||||||
VkImageAspectFlags Aspect,
|
|
||||||
UINT MipLevels,
|
|
||||||
UINT Subresource);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user