1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-14 22:29:15 +01:00

[d3d11] Refactored texture interfaces

All texture classes now use the common info structure
internally as well so that it can be queried efficiently.
This commit is contained in:
Philip Rebohle 2018-01-05 01:15:56 +01:00
parent c816078f13
commit 93a5cf093c
5 changed files with 109 additions and 137 deletions

View File

@ -236,14 +236,10 @@ namespace dxvk {
pMappedResource->DepthPitch = buffer->info().size; pMappedResource->DepthPitch = buffer->info().size;
return S_OK; return S_OK;
} else { } else {
D3D11TextureInfo textureInfo; const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pResource);
if (FAILED(GetCommonTextureInfo(pResource, &textureInfo))) { if (textureInfo->image->mapPtr(0) == nullptr) {
Logger::err("D3D11DeviceContext: Failed to retrieve texture info");
return E_FAIL;
}
if (textureInfo.image->mapPtr(0) == nullptr) {
Logger::err("D3D11DeviceContext: Cannot map a device-local image"); Logger::err("D3D11DeviceContext: Cannot map a device-local image");
return E_FAIL; return E_FAIL;
} }
@ -251,7 +247,7 @@ namespace dxvk {
if (pMappedResource == nullptr) if (pMappedResource == nullptr)
return S_OK; return S_OK;
if (textureInfo.image->isInUse()) { if (textureInfo->image->isInUse()) {
// Don't wait if the application tells us not to // Don't wait if the application tells us not to
if (MapFlags & D3D11_MAP_FLAG_DO_NOT_WAIT) if (MapFlags & D3D11_MAP_FLAG_DO_NOT_WAIT)
return DXGI_ERROR_WAS_STILL_DRAWING; return DXGI_ERROR_WAS_STILL_DRAWING;
@ -260,17 +256,17 @@ namespace dxvk {
this->Synchronize(); this->Synchronize();
} }
const DxvkImageCreateInfo imageInfo = textureInfo.image->info(); const DxvkImageCreateInfo imageInfo = textureInfo->image->info();
const VkImageSubresource imageSubresource = const VkImageSubresource imageSubresource =
GetSubresourceFromIndex(VK_IMAGE_ASPECT_COLOR_BIT, GetSubresourceFromIndex(VK_IMAGE_ASPECT_COLOR_BIT,
imageInfo.mipLevels, Subresource); imageInfo.mipLevels, Subresource);
const VkSubresourceLayout layout = const VkSubresourceLayout layout =
textureInfo.image->querySubresourceLayout(imageSubresource); textureInfo->image->querySubresourceLayout(imageSubresource);
// TODO handle undefined stuff // TODO handle undefined stuff
pMappedResource->pData = textureInfo.image->mapPtr(layout.offset); pMappedResource->pData = textureInfo->image->mapPtr(layout.offset);
pMappedResource->RowPitch = layout.rowPitch; pMappedResource->RowPitch = layout.rowPitch;
pMappedResource->DepthPitch = layout.depthPitch; pMappedResource->DepthPitch = layout.depthPitch;
return S_OK; return S_OK;
@ -355,14 +351,8 @@ namespace dxvk {
if (dstResourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) { if (dstResourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
Logger::err("D3D11DeviceContext::CopySubresourceRegion: Buffers not supported"); Logger::err("D3D11DeviceContext::CopySubresourceRegion: Buffers not supported");
} else { } else {
D3D11TextureInfo dstTextureInfo; const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource);
D3D11TextureInfo srcTextureInfo; const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource);
if (FAILED(GetCommonTextureInfo(pDstResource, &dstTextureInfo))
|| FAILED(GetCommonTextureInfo(pSrcResource, &srcTextureInfo))) {
Logger::err("D3D11DeviceContext: Failed to retrieve DXVK images");
return;
}
VkOffset3D srcOffset = { 0, 0, 0 }; VkOffset3D srcOffset = { 0, 0, 0 };
VkOffset3D dstOffset = { VkOffset3D dstOffset = {
@ -370,7 +360,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->info().extent; VkExtent3D extent = srcTextureInfo->image->info().extent;
if (pSrcBox != nullptr) { if (pSrcBox != nullptr) {
if (pSrcBox->left >= pSrcBox->right if (pSrcBox->left >= pSrcBox->right
@ -387,18 +377,18 @@ namespace dxvk {
extent.depth = pSrcBox->back - pSrcBox->front; extent.depth = pSrcBox->back - pSrcBox->front;
} }
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstTextureInfo.image->info().format); const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstTextureInfo->image->info().format);
const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcTextureInfo.image->info().format); const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcTextureInfo->image->info().format);
const VkImageSubresource dstSubresource = const VkImageSubresource dstSubresource =
GetSubresourceFromIndex( GetSubresourceFromIndex(
dstFormatInfo->aspectMask & srcFormatInfo->aspectMask, dstFormatInfo->aspectMask & srcFormatInfo->aspectMask,
dstTextureInfo.image->info().mipLevels, DstSubresource); dstTextureInfo->image->info().mipLevels, DstSubresource);
const VkImageSubresource srcSubresource = const VkImageSubresource srcSubresource =
GetSubresourceFromIndex( GetSubresourceFromIndex(
dstFormatInfo->aspectMask & srcFormatInfo->aspectMask, dstFormatInfo->aspectMask & srcFormatInfo->aspectMask,
srcTextureInfo.image->info().mipLevels, SrcSubresource); srcTextureInfo->image->info().mipLevels, SrcSubresource);
const VkImageSubresourceLayers dstLayers = { const VkImageSubresourceLayers dstLayers = {
dstSubresource.aspectMask, dstSubresource.aspectMask,
@ -411,8 +401,8 @@ namespace dxvk {
srcSubresource.arrayLayer, 1 }; srcSubresource.arrayLayer, 1 };
m_context->copyImage( m_context->copyImage(
dstTextureInfo.image, dstLayers, dstOffset, dstTextureInfo->image, dstLayers, dstOffset,
srcTextureInfo.image, srcLayers, srcOffset, srcTextureInfo->image, srcLayers, srcOffset,
extent); extent);
} }
} }
@ -615,15 +605,11 @@ namespace dxvk {
size, pSrcData); size, pSrcData);
} }
} else { } else {
D3D11TextureInfo textureInfo; const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pDstResource);
if (FAILED(GetCommonTextureInfo(pDstResource, &textureInfo))) {
Logger::err("D3D11DeviceContext: Failed to retrieve DXVK image");
return;
}
VkOffset3D offset = { 0, 0, 0 }; VkOffset3D offset = { 0, 0, 0 };
VkExtent3D extent = textureInfo.image->info().extent; VkExtent3D extent = textureInfo->image->info().extent;
if (pDstBox != nullptr) { if (pDstBox != nullptr) {
if (pDstBox->left >= pDstBox->right if (pDstBox->left >= pDstBox->right
@ -642,7 +628,7 @@ namespace dxvk {
const VkImageSubresource imageSubresource = const VkImageSubresource imageSubresource =
GetSubresourceFromIndex(VK_IMAGE_ASPECT_COLOR_BIT, GetSubresourceFromIndex(VK_IMAGE_ASPECT_COLOR_BIT,
textureInfo.image->info().mipLevels, DstSubresource); textureInfo->image->info().mipLevels, DstSubresource);
VkImageSubresourceLayers layers; VkImageSubresourceLayers layers;
layers.aspectMask = imageSubresource.aspectMask; layers.aspectMask = imageSubresource.aspectMask;
@ -651,7 +637,7 @@ namespace dxvk {
layers.layerCount = 1; layers.layerCount = 1;
m_context->updateImage( m_context->updateImage(
textureInfo.image, layers, textureInfo->image, layers,
offset, extent, pSrcData, offset, extent, pSrcData,
SrcRowPitch, SrcDepthPitch); SrcRowPitch, SrcDepthPitch);
} }

View File

@ -88,7 +88,7 @@ namespace dxvk {
const Com<D3D11Texture1D> texture const Com<D3D11Texture1D> texture
= new D3D11Texture1D(this, pDesc); = new D3D11Texture1D(this, pDesc);
this->InitTexture(texture->GetDXVKImage(), pInitialData); this->InitTexture(texture->GetTextureInfo()->image, pInitialData);
*ppTexture1D = texture.ref(); *ppTexture1D = texture.ref();
} }
@ -104,7 +104,7 @@ namespace dxvk {
const Com<D3D11Texture2D> texture const Com<D3D11Texture2D> texture
= new D3D11Texture2D(this, pDesc); = new D3D11Texture2D(this, pDesc);
this->InitTexture(texture->GetDXVKImage(), pInitialData); this->InitTexture(texture->GetTextureInfo()->image, pInitialData);
*ppTexture2D = texture.ref(); *ppTexture2D = texture.ref();
} }
@ -120,7 +120,7 @@ namespace dxvk {
const Com<D3D11Texture3D> texture const Com<D3D11Texture3D> texture
= new D3D11Texture3D(this, pDesc); = new D3D11Texture3D(this, pDesc);
this->InitTexture(texture->GetDXVKImage(), pInitialData); this->InitTexture(texture->GetTextureInfo()->image, pInitialData);
*ppTexture3D = texture.ref(); *ppTexture3D = texture.ref();
} }
@ -210,18 +210,14 @@ namespace dxvk {
} }
} else { } else {
// Retrieve info about the image // Retrieve info about the image
D3D11TextureInfo textureInfo; const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pResource);
if (FAILED(GetCommonTextureInfo(pResource, &textureInfo))) {
Logger::err("D3D11Device: Cannot create shader resource view: Invalid texture");
return E_INVALIDARG;
}
// Fill in the view info. The view type depends solely // Fill in the view info. The view type depends solely
// 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->formatMode);
DxvkImageViewCreateInfo viewInfo; DxvkImageViewCreateInfo viewInfo;
viewInfo.format = formatInfo.format; viewInfo.format = formatInfo.format;
@ -309,7 +305,7 @@ namespace dxvk {
} }
if (viewInfo.numLevels == 0 || viewInfo.numLevels == 0xFFFFFFFF) if (viewInfo.numLevels == 0 || viewInfo.numLevels == 0xFFFFFFFF)
viewInfo.numLevels = textureInfo.image->info().mipLevels - viewInfo.minLevel; viewInfo.numLevels = textureInfo->image->info().mipLevels - viewInfo.minLevel;
if (ppSRView == nullptr) if (ppSRView == nullptr)
return S_FALSE; return S_FALSE;
@ -318,7 +314,7 @@ 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->image, viewInfo)));
return S_OK; return S_OK;
} catch (const DxvkError& e) { } catch (const DxvkError& e) {
Logger::err(e.message()); Logger::err(e.message());
@ -392,18 +388,14 @@ namespace dxvk {
} }
} else { } else {
// Retrieve info about the image // Retrieve info about the image
D3D11TextureInfo textureInfo; const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pResource);
if (FAILED(GetCommonTextureInfo(pResource, &textureInfo))) {
Logger::err("D3D11Device: Cannot create unordered access view: Invalid texture");
return E_INVALIDARG;
}
// Fill in the view info. The view type depends solely // Fill in the view info. The view type depends solely
// 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->formatMode);
DxvkImageViewCreateInfo viewInfo; DxvkImageViewCreateInfo viewInfo;
viewInfo.format = formatInfo.format; viewInfo.format = formatInfo.format;
@ -465,7 +457,7 @@ 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->image, viewInfo)));
return S_OK; return S_OK;
} catch (const DxvkError& e) { } catch (const DxvkError& e) {
Logger::err(e.message()); Logger::err(e.message());
@ -500,12 +492,8 @@ 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
D3D11TextureInfo textureInfo; const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pResource);
if (FAILED(GetCommonTextureInfo(pResource, &textureInfo))) {
Logger::err("D3D11Device: Cannot create shader resource view: Invalid texture");
return E_INVALIDARG;
}
// Fill in Vulkan image view info // Fill in Vulkan image view info
DxvkImageViewCreateInfo viewInfo; DxvkImageViewCreateInfo viewInfo;
@ -560,7 +548,7 @@ 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->image, viewInfo)));
return S_OK; return S_OK;
} catch (const DxvkError& e) { } catch (const DxvkError& e) {
Logger::err(e.message()); Logger::err(e.message());
@ -594,12 +582,8 @@ 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
D3D11TextureInfo textureInfo; const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pResource);
if (FAILED(GetCommonTextureInfo(pResource, &textureInfo))) {
Logger::err("D3D11Device: Cannot create shader resource view: Invalid texture");
return E_INVALIDARG;
}
// Fill in Vulkan image view info // Fill in Vulkan image view info
DxvkImageViewCreateInfo viewInfo; DxvkImageViewCreateInfo viewInfo;
@ -654,7 +638,7 @@ 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->image, viewInfo)));
return S_OK; return S_OK;
} catch (const DxvkError& e) { } catch (const DxvkError& e) {
Logger::err(e.message()); Logger::err(e.message());

View File

@ -9,7 +9,7 @@ namespace dxvk {
Rc<DxvkImage> D3D11PresentBackBuffer::GetDXVKImage() { Rc<DxvkImage> D3D11PresentBackBuffer::GetDXVKImage() {
return m_texture->GetDXVKImage(); return m_texture->GetTextureInfo()->image;
} }

View File

@ -126,12 +126,14 @@ namespace dxvk {
D3D11Device* pDevice, D3D11Device* pDevice,
const D3D11_TEXTURE1D_DESC* pDesc) const D3D11_TEXTURE1D_DESC* pDesc)
: m_device (pDevice), : m_device (pDevice),
m_formatMode(GetFormatModeFromBindFlags(pDesc->BindFlags)),
m_desc (*pDesc) { m_desc (*pDesc) {
const DxgiFormatMode formatMode
= GetFormatModeFromBindFlags(pDesc->BindFlags);
DxvkImageCreateInfo info; DxvkImageCreateInfo info;
info.type = VK_IMAGE_TYPE_1D; info.type = VK_IMAGE_TYPE_1D;
info.format = pDevice->LookupFormat(pDesc->Format, m_formatMode).format; info.format = pDevice->LookupFormat(pDesc->Format, formatMode).format;
info.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; info.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
info.sampleCount = VK_SAMPLE_COUNT_1_BIT; info.sampleCount = VK_SAMPLE_COUNT_1_BIT;
info.extent.width = pDesc->Width; info.extent.width = pDesc->Width;
@ -154,8 +156,11 @@ namespace dxvk {
pDesc->MiscFlags, pDesc->MiscFlags,
&info); &info);
m_image = pDevice->GetDXVKDevice()->createImage( // Create the image and, if necessary, the image buffer
m_texInfo.formatMode = formatMode;
m_texInfo.image = pDevice->GetDXVKDevice()->createImage(
info, GetMemoryFlagsForUsage(pDesc->Usage)); info, GetMemoryFlagsForUsage(pDesc->Usage));
m_texInfo.imageBuffer = D3D11ImageBuffer { nullptr, 0, 0 };
} }
/////////////////////////////////////////// ///////////////////////////////////////////
@ -208,12 +213,14 @@ namespace dxvk {
D3D11Device* pDevice, D3D11Device* pDevice,
const D3D11_TEXTURE2D_DESC* pDesc) const D3D11_TEXTURE2D_DESC* pDesc)
: m_device (pDevice), : m_device (pDevice),
m_formatMode(GetFormatModeFromBindFlags(pDesc->BindFlags)),
m_desc (*pDesc) { m_desc (*pDesc) {
const DxgiFormatMode formatMode
= GetFormatModeFromBindFlags(pDesc->BindFlags);
DxvkImageCreateInfo info; DxvkImageCreateInfo info;
info.type = VK_IMAGE_TYPE_2D; info.type = VK_IMAGE_TYPE_2D;
info.format = pDevice->LookupFormat(pDesc->Format, m_formatMode).format; info.format = pDevice->LookupFormat(pDesc->Format, formatMode).format;
info.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; info.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
info.sampleCount = VK_SAMPLE_COUNT_1_BIT; info.sampleCount = VK_SAMPLE_COUNT_1_BIT;
info.extent.width = pDesc->Width; info.extent.width = pDesc->Width;
@ -239,8 +246,11 @@ namespace dxvk {
pDesc->MiscFlags, pDesc->MiscFlags,
&info); &info);
m_image = pDevice->GetDXVKDevice()->createImage( // Create the image and, if necessary, the image buffer
m_texInfo.formatMode = formatMode;
m_texInfo.image = pDevice->GetDXVKDevice()->createImage(
info, GetMemoryFlagsForUsage(pDesc->Usage)); info, GetMemoryFlagsForUsage(pDesc->Usage));
m_texInfo.imageBuffer = D3D11ImageBuffer { nullptr, 0, 0 };
} }
@ -292,12 +302,14 @@ namespace dxvk {
D3D11Device* pDevice, D3D11Device* pDevice,
const D3D11_TEXTURE3D_DESC* pDesc) const D3D11_TEXTURE3D_DESC* pDesc)
: m_device (pDevice), : m_device (pDevice),
m_formatMode(GetFormatModeFromBindFlags(pDesc->BindFlags)),
m_desc (*pDesc) { m_desc (*pDesc) {
const DxgiFormatMode formatMode
= GetFormatModeFromBindFlags(pDesc->BindFlags);
DxvkImageCreateInfo info; DxvkImageCreateInfo info;
info.type = VK_IMAGE_TYPE_3D; info.type = VK_IMAGE_TYPE_3D;
info.format = pDevice->LookupFormat(pDesc->Format, m_formatMode).format; info.format = pDevice->LookupFormat(pDesc->Format, formatMode).format;
info.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT info.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT
| VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR; | VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR;
info.sampleCount = VK_SAMPLE_COUNT_1_BIT; info.sampleCount = VK_SAMPLE_COUNT_1_BIT;
@ -321,8 +333,11 @@ namespace dxvk {
pDesc->MiscFlags, pDesc->MiscFlags,
&info); &info);
m_image = pDevice->GetDXVKDevice()->createImage( // Create the image and, if necessary, the image buffer
m_texInfo.formatMode = formatMode;
m_texInfo.image = pDevice->GetDXVKDevice()->createImage(
info, GetMemoryFlagsForUsage(pDesc->Usage)); info, GetMemoryFlagsForUsage(pDesc->Usage));
m_texInfo.imageBuffer = D3D11ImageBuffer { nullptr, 0, 0 };
} }
@ -369,33 +384,22 @@ namespace dxvk {
HRESULT GetCommonTextureInfo( const D3D11TextureInfo* GetCommonTextureInfo(ID3D11Resource* pResource) {
ID3D11Resource* pResource,
D3D11TextureInfo* pTextureInfo) {
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:
auto tex = static_cast<D3D11Texture1D*>(pResource); return static_cast<D3D11Texture1D*>(pResource)->GetTextureInfo();
pTextureInfo->formatMode = tex->GetFormatMode();
pTextureInfo->image = tex->GetDXVKImage();
} return S_OK;
case D3D11_RESOURCE_DIMENSION_TEXTURE2D: { case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
auto tex = static_cast<D3D11Texture2D*>(pResource); return static_cast<D3D11Texture2D*>(pResource)->GetTextureInfo();
pTextureInfo->formatMode = tex->GetFormatMode();
pTextureInfo->image = tex->GetDXVKImage();
} return S_OK;
case D3D11_RESOURCE_DIMENSION_TEXTURE3D: { case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
auto tex = static_cast<D3D11Texture3D*>(pResource); return static_cast<D3D11Texture3D*>(pResource)->GetTextureInfo();
pTextureInfo->formatMode = tex->GetFormatMode();
pTextureInfo->image = tex->GetDXVKImage();
} return S_OK;
default: default:
return E_INVALIDARG; return nullptr;
} }
} }

View File

@ -9,6 +9,32 @@ namespace dxvk {
class D3D11Device; class D3D11Device;
/**
* \brief Image buffer info
*
* Stores the buffer used for mapping
* an image and the row/layer strides.
*/
struct D3D11ImageBuffer {
Rc<DxvkBuffer> buffer;
VkDeviceSize bytesPerRow;
VkDeviceSize bytesPerLayer;
};
/**
* \brief Common texture info
*
* Stores the image and the image format
* mode for a texture of any type.
*/
struct D3D11TextureInfo {
DxgiFormatMode formatMode;
D3D11ImageBuffer imageBuffer;
Rc<DxvkImage> image;
};
/////////////////////////////////////////// ///////////////////////////////////////////
// D 3 D 1 1 T E X T U R E 1 D // D 3 D 1 1 T E X T U R E 1 D
class D3D11Texture1D : public D3D11DeviceChild<ID3D11Texture1D> { class D3D11Texture1D : public D3D11DeviceChild<ID3D11Texture1D> {
@ -38,20 +64,15 @@ namespace dxvk {
void STDMETHODCALLTYPE GetDesc( void STDMETHODCALLTYPE GetDesc(
D3D11_TEXTURE1D_DESC *pDesc) final; D3D11_TEXTURE1D_DESC *pDesc) final;
DxgiFormatMode GetFormatMode() const { const D3D11TextureInfo* GetTextureInfo() const {
return m_formatMode; return &m_texInfo;
}
Rc<DxvkImage> GetDXVKImage() const {
return m_image;
} }
private: private:
Com<D3D11Device> m_device; Com<D3D11Device> m_device;
DxgiFormatMode m_formatMode;
D3D11_TEXTURE1D_DESC m_desc; D3D11_TEXTURE1D_DESC m_desc;
Rc<DxvkImage> m_image; D3D11TextureInfo m_texInfo;
}; };
@ -85,20 +106,15 @@ namespace dxvk {
void STDMETHODCALLTYPE GetDesc( void STDMETHODCALLTYPE GetDesc(
D3D11_TEXTURE2D_DESC *pDesc) final; D3D11_TEXTURE2D_DESC *pDesc) final;
DxgiFormatMode GetFormatMode() const { const D3D11TextureInfo* GetTextureInfo() const {
return m_formatMode; return &m_texInfo;
}
Rc<DxvkImage> GetDXVKImage() const {
return m_image;
} }
private: private:
Com<D3D11Device> m_device; Com<D3D11Device> m_device;
DxgiFormatMode m_formatMode;
D3D11_TEXTURE2D_DESC m_desc; D3D11_TEXTURE2D_DESC m_desc;
Rc<DxvkImage> m_image; D3D11TextureInfo m_texInfo;
}; };
@ -132,36 +148,19 @@ namespace dxvk {
void STDMETHODCALLTYPE GetDesc( void STDMETHODCALLTYPE GetDesc(
D3D11_TEXTURE3D_DESC *pDesc) final; D3D11_TEXTURE3D_DESC *pDesc) final;
DxgiFormatMode GetFormatMode() const { const D3D11TextureInfo* GetTextureInfo() const {
return m_formatMode; return &m_texInfo;
}
Rc<DxvkImage> GetDXVKImage() const {
return m_image;
} }
private: private:
Com<D3D11Device> m_device; Com<D3D11Device> m_device;
DxgiFormatMode m_formatMode;
D3D11_TEXTURE3D_DESC m_desc; D3D11_TEXTURE3D_DESC m_desc;
Rc<DxvkImage> m_image; D3D11TextureInfo m_texInfo;
}; };
/**
* \brief Common texture info
*
* Stores the image and the image format
* mode for a texture of any type.
*/
struct D3D11TextureInfo {
DxgiFormatMode formatMode;
Rc<DxvkImage> image;
};
/** /**
* \brief Retrieves common info about a texture * \brief Retrieves common info about a texture
* *
@ -169,9 +168,8 @@ 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
*/ */
HRESULT GetCommonTextureInfo( const D3D11TextureInfo* GetCommonTextureInfo(
ID3D11Resource* pResource, ID3D11Resource* pResource);
D3D11TextureInfo* pTextureInfo);
/** /**
* \brief Computes image subresource from subresource index * \brief Computes image subresource from subresource index