mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +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());
|
||||
});
|
||||
} else {
|
||||
const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource);
|
||||
const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource);
|
||||
const D3D11CommonTexture* dstTextureInfo = GetCommonTexture(pDstResource);
|
||||
const D3D11CommonTexture* srcTextureInfo = GetCommonTexture(pSrcResource);
|
||||
|
||||
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstTextureInfo->image->info().format);
|
||||
const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcTextureInfo->image->info().format);
|
||||
const Rc<DxvkImage> dstImage = dstTextureInfo->GetImage();
|
||||
const Rc<DxvkImage> srcImage = srcTextureInfo->GetImage();
|
||||
|
||||
const VkImageSubresource dstSubresource = GetSubresourceFromIndex(dstFormatInfo->aspectMask, dstTextureInfo->image->info().mipLevels, DstSubresource);
|
||||
const VkImageSubresource srcSubresource = GetSubresourceFromIndex(srcFormatInfo->aspectMask, srcTextureInfo->image->info().mipLevels, SrcSubresource);
|
||||
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstImage->info().format);
|
||||
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 dstOffset = {
|
||||
@ -332,7 +335,7 @@ namespace dxvk {
|
||||
static_cast<int32_t>(DstY),
|
||||
static_cast<int32_t>(DstZ) };
|
||||
|
||||
VkExtent3D extent = srcTextureInfo->image->mipLevelExtent(srcSubresource.mipLevel);
|
||||
VkExtent3D extent = srcImage->mipLevelExtent(srcSubresource.mipLevel);
|
||||
|
||||
if (pSrcBox != nullptr) {
|
||||
if (pSrcBox->left >= pSrcBox->right
|
||||
@ -360,8 +363,8 @@ namespace dxvk {
|
||||
srcSubresource.arrayLayer, 1 };
|
||||
|
||||
EmitCs([
|
||||
cDstImage = dstTextureInfo->image,
|
||||
cSrcImage = srcTextureInfo->image,
|
||||
cDstImage = dstImage,
|
||||
cSrcImage = srcImage,
|
||||
cDstLayers = dstLayers,
|
||||
cSrcLayers = srcLayers,
|
||||
cDstOffset = dstOffset,
|
||||
@ -412,21 +415,21 @@ namespace dxvk {
|
||||
cSrcBuffer.length());
|
||||
});
|
||||
} else {
|
||||
const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource);
|
||||
const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource);
|
||||
const Rc<DxvkImage> dstImage = GetCommonTexture(pDstResource)->GetImage();
|
||||
const Rc<DxvkImage> srcImage = GetCommonTexture(pSrcResource)->GetImage();
|
||||
|
||||
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstTextureInfo->image->info().format);
|
||||
const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcTextureInfo->image->info().format);
|
||||
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstImage->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++) {
|
||||
VkExtent3D extent = srcTextureInfo->image->mipLevelExtent(i);
|
||||
|
||||
const VkImageSubresourceLayers dstLayers = { dstFormatInfo->aspectMask, i, 0, dstTextureInfo->image->info().numLayers };
|
||||
const VkImageSubresourceLayers srcLayers = { srcFormatInfo->aspectMask, i, 0, srcTextureInfo->image->info().numLayers };
|
||||
const VkImageSubresourceLayers dstLayers = { dstFormatInfo->aspectMask, i, 0, dstImage->info().numLayers };
|
||||
const VkImageSubresourceLayers srcLayers = { srcFormatInfo->aspectMask, i, 0, srcImage->info().numLayers };
|
||||
|
||||
EmitCs([
|
||||
cDstImage = dstTextureInfo->image,
|
||||
cSrcImage = srcTextureInfo->image,
|
||||
cDstImage = dstImage,
|
||||
cSrcImage = srcImage,
|
||||
cDstLayers = dstLayers,
|
||||
cSrcLayers = srcLayers,
|
||||
cExtent = extent
|
||||
@ -723,15 +726,14 @@ namespace dxvk {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const D3D11TextureInfo* textureInfo
|
||||
= GetCommonTextureInfo(pDstResource);
|
||||
const D3D11CommonTexture* textureInfo = GetCommonTexture(pDstResource);
|
||||
|
||||
const VkImageSubresource subresource =
|
||||
GetSubresourceFromIndex(VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
textureInfo->image->info().mipLevels, DstSubresource);
|
||||
textureInfo->GetSubresourceFromIndex(
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, DstSubresource);
|
||||
|
||||
VkOffset3D offset = { 0, 0, 0 };
|
||||
VkExtent3D extent = textureInfo->image->mipLevelExtent(subresource.mipLevel);
|
||||
VkExtent3D extent = textureInfo->GetImage()->mipLevelExtent(subresource.mipLevel);
|
||||
|
||||
if (pDstBox != nullptr) {
|
||||
if (pDstBox->left >= pDstBox->right
|
||||
@ -754,7 +756,7 @@ namespace dxvk {
|
||||
subresource.arrayLayer, 1 };
|
||||
|
||||
auto formatInfo = imageFormatInfo(
|
||||
textureInfo->image->info().format);
|
||||
textureInfo->GetImage()->info().format);
|
||||
|
||||
const VkExtent3D regionExtent = util::computeBlockCount(extent, formatInfo->blockSize);
|
||||
|
||||
@ -771,7 +773,7 @@ namespace dxvk {
|
||||
SrcRowPitch, SrcDepthPitch);
|
||||
|
||||
EmitCs([
|
||||
cDstImage = textureInfo->image,
|
||||
cDstImage = textureInfo->GetImage(),
|
||||
cDstLayers = layers,
|
||||
cDstOffset = offset,
|
||||
cDstExtent = extent,
|
||||
@ -832,19 +834,19 @@ namespace dxvk {
|
||||
return;
|
||||
}
|
||||
|
||||
const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource);
|
||||
const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource);
|
||||
const D3D11CommonTexture* dstTextureInfo = GetCommonTexture(pDstResource);
|
||||
const D3D11CommonTexture* srcTextureInfo = GetCommonTexture(pSrcResource);
|
||||
|
||||
const DxgiFormatInfo dstFormatInfo = m_parent->LookupFormat(dstDesc.Format, DxgiFormatMode::Any);
|
||||
const DxgiFormatInfo srcFormatInfo = m_parent->LookupFormat(srcDesc.Format, DxgiFormatMode::Any);
|
||||
|
||||
const VkImageSubresource dstSubresource =
|
||||
GetSubresourceFromIndex(dstFormatInfo.aspect,
|
||||
dstTextureInfo->image->info().mipLevels, DstSubresource);
|
||||
dstTextureInfo->GetSubresourceFromIndex(
|
||||
dstFormatInfo.aspect, DstSubresource);
|
||||
|
||||
const VkImageSubresource srcSubresource =
|
||||
GetSubresourceFromIndex(srcFormatInfo.aspect,
|
||||
srcTextureInfo->image->info().mipLevels, SrcSubresource);
|
||||
srcTextureInfo->GetSubresourceFromIndex(
|
||||
srcFormatInfo.aspect, SrcSubresource);
|
||||
|
||||
const VkImageSubresourceLayers dstSubresourceLayers = {
|
||||
dstSubresource.aspectMask,
|
||||
@ -858,8 +860,8 @@ namespace dxvk {
|
||||
|
||||
if (srcDesc.SampleDesc.Count == 1) {
|
||||
EmitCs([
|
||||
cDstImage = dstTextureInfo->image,
|
||||
cSrcImage = srcTextureInfo->image,
|
||||
cDstImage = dstTextureInfo->GetImage(),
|
||||
cSrcImage = srcTextureInfo->GetImage(),
|
||||
cDstLayers = dstSubresourceLayers,
|
||||
cSrcLayers = srcSubresourceLayers
|
||||
] (DxvkContext* ctx) {
|
||||
@ -873,8 +875,8 @@ namespace dxvk {
|
||||
Format, DxgiFormatMode::Any).format;
|
||||
|
||||
EmitCs([
|
||||
cDstImage = dstTextureInfo->image,
|
||||
cSrcImage = srcTextureInfo->image,
|
||||
cDstImage = dstTextureInfo->GetImage(),
|
||||
cSrcImage = srcTextureInfo->GetImage(),
|
||||
cDstSubres = dstSubresourceLayers,
|
||||
cSrcSubres = srcSubresourceLayers,
|
||||
cFormat = format
|
||||
|
@ -143,103 +143,83 @@ namespace dxvk {
|
||||
pMappedResource->DepthPitch = physicalSlice.length();
|
||||
return S_OK;
|
||||
} else {
|
||||
// Depending on whether the image has been allocated on a
|
||||
// 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();
|
||||
D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||
|
||||
textureInfo->mappedSubresource = GetSubresourceFromIndex(
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, imageInfo.mipLevels, Subresource);
|
||||
const Rc<DxvkImage> mappedImage = textureInfo->GetImage();
|
||||
const Rc<DxvkBuffer> mappedBuffer = textureInfo->GetMappedBuffer();
|
||||
|
||||
if (textureInfo->image->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
|
||||
const VkSubresourceLayout subresourceLayout =
|
||||
textureInfo->image->querySubresourceLayout(
|
||||
textureInfo->mappedSubresource);
|
||||
if (mappedBuffer == nullptr) {
|
||||
Logger::err("D3D11: Cannot map a device-local image");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
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))
|
||||
return DXGI_ERROR_WAS_STILL_DRAWING;
|
||||
|
||||
pMappedResource->pData = textureInfo->image->mapPtr(subresourceLayout.offset);
|
||||
pMappedResource->RowPitch = subresourceLayout.rowPitch;
|
||||
pMappedResource->DepthPitch = subresourceLayout.rowPitch * imageInfo.extent.height;
|
||||
|
||||
if (imageInfo.type == VK_IMAGE_TYPE_3D)
|
||||
pMappedResource->DepthPitch = subresourceLayout.depthPitch;
|
||||
else if (imageInfo.numLayers > 1)
|
||||
pMappedResource->DepthPitch = subresourceLayout.arrayPitch;
|
||||
|
||||
return S_OK;
|
||||
EmitCs([
|
||||
cImageBuffer = mappedBuffer,
|
||||
cPhysicalSlice = physicalSlice
|
||||
] (DxvkContext* ctx) {
|
||||
ctx->invalidateBuffer(cImageBuffer, cPhysicalSlice);
|
||||
cPhysicalSlice.resource()->release();
|
||||
});
|
||||
} else {
|
||||
if (textureInfo->imageBuffer == nullptr) {
|
||||
Logger::err("D3D11: Cannot map a device-local image");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
// 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->Desc()->Usage == D3D11_USAGE_STAGING;
|
||||
|
||||
if (pMappedResource == nullptr)
|
||||
return S_FALSE;
|
||||
|
||||
// Query format info in order to compute
|
||||
// the row pitch and layer pitch properly.
|
||||
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();
|
||||
if (copyExistingData) {
|
||||
const VkImageSubresourceLayers subresourceLayers = {
|
||||
subresource.aspectMask,
|
||||
subresource.mipLevel,
|
||||
subresource.arrayLayer, 1 };
|
||||
|
||||
EmitCs([
|
||||
cImageBuffer = textureInfo->imageBuffer,
|
||||
cPhysicalSlice = physicalSlice
|
||||
cImageBuffer = mappedBuffer,
|
||||
cImage = mappedImage,
|
||||
cSubresources = subresourceLayers,
|
||||
cLevelExtent = levelExtent
|
||||
] (DxvkContext* ctx) {
|
||||
ctx->invalidateBuffer(cImageBuffer, cPhysicalSlice);
|
||||
cPhysicalSlice.resource()->release();
|
||||
ctx->copyImageToBuffer(
|
||||
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.
|
||||
pMappedResource->pData = physicalSlice.mapPtr(0);
|
||||
pMappedResource->RowPitch = formatInfo->elementSize * blockCount.width;
|
||||
pMappedResource->DepthPitch = formatInfo->elementSize * blockCount.width * blockCount.height;
|
||||
return S_OK;
|
||||
if (!WaitForResource(mappedBuffer->resource(), MapFlags))
|
||||
return DXGI_ERROR_WAS_STILL_DRAWING;
|
||||
|
||||
physicalSlice = mappedBuffer->slice();
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// Now that data has been written into the buffer,
|
||||
// we need to copy its contents into the image
|
||||
const D3D11TextureInfo* textureInfo
|
||||
= GetCommonTextureInfo(pResource);
|
||||
D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||
|
||||
if (!(textureInfo->image->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) {
|
||||
const VkExtent3D levelExtent = textureInfo->image
|
||||
->mipLevelExtent(textureInfo->mappedSubresource.mipLevel);
|
||||
|
||||
const VkImageSubresourceLayers subresourceLayers = {
|
||||
textureInfo->mappedSubresource.aspectMask,
|
||||
textureInfo->mappedSubresource.mipLevel,
|
||||
textureInfo->mappedSubresource.arrayLayer, 1 };
|
||||
|
||||
EmitCs([
|
||||
cSrcBuffer = textureInfo->imageBuffer,
|
||||
cDstImage = textureInfo->image,
|
||||
cDstLayers = subresourceLayers,
|
||||
cDstLevelExtent = levelExtent
|
||||
] (DxvkContext* ctx) {
|
||||
ctx->copyBufferToImage(cDstImage, cDstLayers,
|
||||
VkOffset3D { 0, 0, 0 }, cDstLevelExtent,
|
||||
cSrcBuffer, 0, { 0u, 0u });
|
||||
});
|
||||
}
|
||||
const Rc<DxvkImage> mappedImage = textureInfo->GetImage();
|
||||
const Rc<DxvkBuffer> mappedBuffer = textureInfo->GetMappedBuffer();
|
||||
|
||||
VkImageSubresource subresource = textureInfo->GetMappedSubresource();
|
||||
|
||||
VkExtent3D levelExtent = mappedImage
|
||||
->mipLevelExtent(subresource.mipLevel);
|
||||
|
||||
VkImageSubresourceLayers subresourceLayers = {
|
||||
subresource.aspectMask,
|
||||
subresource.mipLevel,
|
||||
subresource.arrayLayer, 1 };
|
||||
|
||||
EmitCs([
|
||||
cSrcBuffer = mappedBuffer,
|
||||
cDstImage = mappedImage,
|
||||
cDstLayers = subresourceLayers,
|
||||
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;
|
||||
|
||||
try {
|
||||
const Com<D3D11Texture1D> texture
|
||||
= new D3D11Texture1D(this, &desc);
|
||||
|
||||
this->InitTexture(texture->GetTextureInfo()->image, pInitialData);
|
||||
const Com<D3D11Texture1D> texture = new D3D11Texture1D(this, &desc);
|
||||
this->InitTexture(texture->GetCommonTexture()->GetImage(), pInitialData);
|
||||
*ppTexture1D = texture.ref();
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
@ -160,10 +158,8 @@ namespace dxvk {
|
||||
return S_FALSE;
|
||||
|
||||
try {
|
||||
const Com<D3D11Texture2D> texture
|
||||
= new D3D11Texture2D(this, &desc);
|
||||
|
||||
this->InitTexture(texture->GetTextureInfo()->image, pInitialData);
|
||||
const Com<D3D11Texture2D> texture = new D3D11Texture2D(this, &desc);
|
||||
this->InitTexture(texture->GetCommonTexture()->GetImage(), pInitialData);
|
||||
*ppTexture2D = texture.ref();
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
@ -197,10 +193,8 @@ namespace dxvk {
|
||||
return S_FALSE;
|
||||
|
||||
try {
|
||||
const Com<D3D11Texture3D> texture
|
||||
= new D3D11Texture3D(this, &desc);
|
||||
|
||||
this->InitTexture(texture->GetTextureInfo()->image, pInitialData);
|
||||
const Com<D3D11Texture3D> texture = new D3D11Texture3D(this, &desc);
|
||||
this->InitTexture(texture->GetCommonTexture()->GetImage(), pInitialData);
|
||||
*ppTexture3D = texture.ref();
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
@ -299,11 +293,9 @@ namespace dxvk {
|
||||
return E_FAIL;
|
||||
}
|
||||
} else {
|
||||
// Retrieve info about the image
|
||||
const D3D11TextureInfo* textureInfo
|
||||
= GetCommonTextureInfo(pResource);
|
||||
const D3D11CommonTexture* textureInfo = GetCommonTexture(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");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
@ -312,7 +304,7 @@ namespace dxvk {
|
||||
// on the view dimension field in the view description,
|
||||
// not on the resource type.
|
||||
const DxgiFormatInfo formatInfo = m_dxgiAdapter
|
||||
->LookupFormat(desc.Format, textureInfo->formatMode);
|
||||
->LookupFormat(desc.Format, textureInfo->GetFormatMode());
|
||||
|
||||
DxvkImageViewCreateInfo viewInfo;
|
||||
viewInfo.format = formatInfo.format;
|
||||
@ -406,7 +398,8 @@ namespace dxvk {
|
||||
*ppSRView = ref(new D3D11ShaderResourceView(
|
||||
this, pResource, desc,
|
||||
m_dxvkDevice->createImageView(
|
||||
textureInfo->image, viewInfo)));
|
||||
textureInfo->GetImage(),
|
||||
viewInfo)));
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
Logger::err(e.message());
|
||||
@ -495,11 +488,9 @@ namespace dxvk {
|
||||
return E_FAIL;
|
||||
}
|
||||
} else {
|
||||
// Retrieve info about the image
|
||||
const D3D11TextureInfo* textureInfo
|
||||
= GetCommonTextureInfo(pResource);
|
||||
const D3D11CommonTexture* textureInfo = GetCommonTexture(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");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
@ -508,7 +499,7 @@ namespace dxvk {
|
||||
// on the view dimension field in the view description,
|
||||
// not on the resource type.
|
||||
const DxgiFormatInfo formatInfo = m_dxgiAdapter
|
||||
->LookupFormat(desc.Format, textureInfo->formatMode);
|
||||
->LookupFormat(desc.Format, textureInfo->GetFormatMode());
|
||||
|
||||
DxvkImageViewCreateInfo viewInfo;
|
||||
viewInfo.format = formatInfo.format;
|
||||
@ -572,7 +563,8 @@ namespace dxvk {
|
||||
*ppUAView = ref(new D3D11UnorderedAccessView(
|
||||
this, pResource, desc,
|
||||
m_dxvkDevice->createImageView(
|
||||
textureInfo->image, viewInfo),
|
||||
textureInfo->GetImage(),
|
||||
viewInfo),
|
||||
DxvkBufferSlice()));
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
@ -606,10 +598,9 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
// Retrieve the image that we are going to create the view for
|
||||
const D3D11TextureInfo* textureInfo
|
||||
= GetCommonTextureInfo(pResource);
|
||||
const D3D11CommonTexture* textureInfo = GetCommonTexture(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");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
@ -691,7 +682,8 @@ namespace dxvk {
|
||||
*ppRTView = ref(new D3D11RenderTargetView(
|
||||
this, pResource, desc,
|
||||
m_dxvkDevice->createImageView(
|
||||
textureInfo->image, viewInfo)));
|
||||
textureInfo->GetImage(),
|
||||
viewInfo)));
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
Logger::err(e.message());
|
||||
@ -723,10 +715,9 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
// Retrieve the image that we are going to create the view for
|
||||
const D3D11TextureInfo* textureInfo
|
||||
= GetCommonTextureInfo(pResource);
|
||||
const D3D11CommonTexture* textureInfo = GetCommonTexture(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");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
@ -800,7 +791,8 @@ namespace dxvk {
|
||||
*ppDepthStencilView = ref(new D3D11DepthStencilView(
|
||||
this, pResource, desc,
|
||||
m_dxvkDevice->createImageView(
|
||||
textureInfo->image, viewInfo)));
|
||||
textureInfo->GetImage(),
|
||||
viewInfo)));
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
Logger::err(e.message());
|
||||
|
@ -10,7 +10,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
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
|
||||
? CreateImageBuffer(m_device->GetDXVKDevice(), info.format, info.extent)
|
||||
: 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(
|
||||
VkImageAspectFlags Aspect,
|
||||
UINT Subresource) {
|
||||
UINT Subresource) const {
|
||||
VkImageSubresource result;
|
||||
result.aspectMask = Aspect;
|
||||
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;
|
||||
pResource->GetType(&dimension);
|
||||
|
||||
switch (dimension) {
|
||||
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
|
||||
return static_cast<D3D11Texture1D*>(pResource)->GetTextureInfo();
|
||||
return static_cast<D3D11Texture1D*>(pResource)->GetCommonTexture();
|
||||
|
||||
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
|
||||
return static_cast<D3D11Texture2D*>(pResource)->GetTextureInfo();
|
||||
return static_cast<D3D11Texture2D*>(pResource)->GetCommonTexture();
|
||||
|
||||
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
|
||||
return static_cast<D3D11Texture3D*>(pResource)->GetTextureInfo();
|
||||
return static_cast<D3D11Texture3D*>(pResource)->GetCommonTexture();
|
||||
|
||||
default:
|
||||
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;
|
||||
|
||||
/**
|
||||
* \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
|
||||
*
|
||||
@ -78,19 +59,11 @@ namespace dxvk {
|
||||
return &m_desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Texture info
|
||||
* \todo NUKE THIS
|
||||
*/
|
||||
D3D11TextureInfo* GetTextureInfo() {
|
||||
return &m_texinfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief The DXVK image
|
||||
* \returns The DXVK image
|
||||
*/
|
||||
Rc<DxvkImage> GetDxvkImage() const {
|
||||
Rc<DxvkImage> GetImage() const {
|
||||
return m_image;
|
||||
}
|
||||
|
||||
@ -98,7 +71,7 @@ namespace dxvk {
|
||||
* \brief The DXVK buffer
|
||||
* \returns The DXVK buffer
|
||||
*/
|
||||
Rc<DxvkBuffer> GetDxvkBuffer() const {
|
||||
Rc<DxvkBuffer> GetMappedBuffer() const {
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
@ -137,7 +110,7 @@ namespace dxvk {
|
||||
*/
|
||||
VkImageSubresource GetSubresourceFromIndex(
|
||||
VkImageAspectFlags Aspect,
|
||||
UINT Subresource);
|
||||
UINT Subresource) const;
|
||||
|
||||
/**
|
||||
* \brief Format mode
|
||||
@ -177,9 +150,6 @@ namespace dxvk {
|
||||
VkImageSubresource m_mappedSubresource
|
||||
= { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 };
|
||||
|
||||
// TODO get rid of this
|
||||
D3D11TextureInfo m_texinfo;
|
||||
|
||||
static VkImageType GetImageTypeFromResourceDim(
|
||||
D3D11_RESOURCE_DIMENSION Dimension);
|
||||
|
||||
@ -215,8 +185,8 @@ namespace dxvk {
|
||||
void STDMETHODCALLTYPE GetDesc(
|
||||
D3D11_TEXTURE1D_DESC *pDesc) final;
|
||||
|
||||
D3D11TextureInfo* GetTextureInfo() {
|
||||
return m_texture.GetTextureInfo();
|
||||
D3D11CommonTexture* GetCommonTexture() {
|
||||
return &m_texture;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -255,8 +225,8 @@ namespace dxvk {
|
||||
void STDMETHODCALLTYPE GetDesc(
|
||||
D3D11_TEXTURE2D_DESC *pDesc) final;
|
||||
|
||||
D3D11TextureInfo* GetTextureInfo() {
|
||||
return m_texture.GetTextureInfo();
|
||||
D3D11CommonTexture* GetCommonTexture() {
|
||||
return &m_texture;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -295,8 +265,8 @@ namespace dxvk {
|
||||
void STDMETHODCALLTYPE GetDesc(
|
||||
D3D11_TEXTURE3D_DESC *pDesc) final;
|
||||
|
||||
D3D11TextureInfo* GetTextureInfo() {
|
||||
return m_texture.GetTextureInfo();
|
||||
D3D11CommonTexture* GetCommonTexture() {
|
||||
return &m_texture;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -313,20 +283,7 @@ namespace dxvk {
|
||||
* \param [out] pTextureInfo Pointer to the texture info struct.
|
||||
* \returns E_INVALIDARG if the resource is not a texture
|
||||
*/
|
||||
D3D11TextureInfo* GetCommonTextureInfo(
|
||||
D3D11CommonTexture* GetCommonTexture(
|
||||
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