mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-06 13:54:14 +01:00
[d3d11] Use new resource helper functions during view creation
This simplifies things when both buffers and textures are allowed.
This commit is contained in:
parent
b87f3f5155
commit
16315a39a0
@ -10,6 +10,7 @@
|
|||||||
#include "d3d11_interop.h"
|
#include "d3d11_interop.h"
|
||||||
#include "d3d11_present.h"
|
#include "d3d11_present.h"
|
||||||
#include "d3d11_query.h"
|
#include "d3d11_query.h"
|
||||||
|
#include "d3d11_resource.h"
|
||||||
#include "d3d11_sampler.h"
|
#include "d3d11_sampler.h"
|
||||||
#include "d3d11_shader.h"
|
#include "d3d11_shader.h"
|
||||||
#include "d3d11_texture.h"
|
#include "d3d11_texture.h"
|
||||||
@ -287,17 +288,24 @@ namespace dxvk {
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check whether SRVs are supported for the resource at all
|
||||||
|
if (!CheckResourceBindFlags(pResource, D3D11_BIND_SHADER_RESOURCE)) {
|
||||||
|
Logger::err("D3D11: Trying to create SRV for texture without D3D11_BIND_SHADER_RESOURCE");
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check whether we can use the requested format for the view
|
||||||
|
if (!CheckResourceViewFormatCompatibility(pResource, desc.Format)) {
|
||||||
|
Logger::err(str::format("D3D11: Incompatible SRV format: ", desc.Format));
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
if (resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
if (resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||||
auto resource = static_cast<D3D11Buffer*>(pResource);
|
auto resource = static_cast<D3D11Buffer*>(pResource);
|
||||||
|
|
||||||
D3D11_BUFFER_DESC resourceDesc;
|
D3D11_BUFFER_DESC resourceDesc;
|
||||||
resource->GetDesc(&resourceDesc);
|
resource->GetDesc(&resourceDesc);
|
||||||
|
|
||||||
if ((resourceDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE) == 0) {
|
|
||||||
Logger::warn("D3D11: Trying to create SRV for buffer without D3D11_BIND_SHADER_RESOURCE");
|
|
||||||
return E_INVALIDARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
DxvkBufferViewCreateInfo viewInfo;
|
DxvkBufferViewCreateInfo viewInfo;
|
||||||
|
|
||||||
D3D11_BUFFEREX_SRV bufInfo;
|
D3D11_BUFFEREX_SRV bufInfo;
|
||||||
@ -357,19 +365,6 @@ namespace dxvk {
|
|||||||
} else {
|
} else {
|
||||||
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
|
|
||||||
if ((textureInfo->Desc()->BindFlags & D3D11_BIND_SHADER_RESOURCE) == 0) {
|
|
||||||
Logger::err("D3D11: Trying to create SRV for texture without D3D11_BIND_SHADER_RESOURCE");
|
|
||||||
return E_INVALIDARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether we can use the requested format for the view
|
|
||||||
if (!textureInfo->CheckViewFormatCompatibility(desc.Format)) {
|
|
||||||
Logger::err(str::format("D3D11: Incompatible SRV formats",
|
|
||||||
"\n Base format: ", textureInfo->Desc()->Format,
|
|
||||||
"\n View format: ", desc.Format));
|
|
||||||
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.
|
||||||
@ -510,17 +505,24 @@ namespace dxvk {
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check whether UAVs are supported for the resource at all
|
||||||
|
if (!CheckResourceBindFlags(pResource, D3D11_BIND_UNORDERED_ACCESS)) {
|
||||||
|
Logger::err("D3D11: Trying to create UAV for texture without D3D11_BIND_UNORDERED_ACCESS");
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check whether we can use the requested format for the view
|
||||||
|
if (!CheckResourceViewFormatCompatibility(pResource, desc.Format)) {
|
||||||
|
Logger::err(str::format("D3D11: Incompatible UAV format: ", desc.Format));
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
if (resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
if (resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||||
auto resource = static_cast<D3D11Buffer*>(pResource);
|
auto resource = static_cast<D3D11Buffer*>(pResource);
|
||||||
|
|
||||||
D3D11_BUFFER_DESC resourceDesc;
|
D3D11_BUFFER_DESC resourceDesc;
|
||||||
resource->GetDesc(&resourceDesc);
|
resource->GetDesc(&resourceDesc);
|
||||||
|
|
||||||
if ((resourceDesc.BindFlags & D3D11_BIND_UNORDERED_ACCESS) == 0) {
|
|
||||||
Logger::warn("D3D11: Trying to create UAV for buffer without D3D11_BIND_UNORDERED_ACCESS");
|
|
||||||
return E_INVALIDARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
DxvkBufferViewCreateInfo viewInfo;
|
DxvkBufferViewCreateInfo viewInfo;
|
||||||
|
|
||||||
if (desc.Buffer.Flags & D3D11_BUFFEREX_SRV_FLAG_RAW) {
|
if (desc.Buffer.Flags & D3D11_BUFFEREX_SRV_FLAG_RAW) {
|
||||||
@ -570,19 +572,6 @@ namespace dxvk {
|
|||||||
} else {
|
} else {
|
||||||
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether we can use the requested format for the view
|
|
||||||
if (!textureInfo->CheckViewFormatCompatibility(desc.Format)) {
|
|
||||||
Logger::err(str::format("D3D11: Incompatible UAV formats",
|
|
||||||
"\n Base format: ", textureInfo->Desc()->Format,
|
|
||||||
"\n View format: ", desc.Format));
|
|
||||||
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.
|
||||||
@ -693,22 +682,21 @@ namespace dxvk {
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the image that we are going to create the view for
|
// Check whether UAVs are supported for the resource at all
|
||||||
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
if (!CheckResourceBindFlags(pResource, D3D11_BIND_RENDER_TARGET)) {
|
||||||
|
Logger::err("D3D11: Trying to create RTV for texture without D3D11_BIND_RENDER_TARGET");
|
||||||
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;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether we can use the requested format for the view
|
// Check whether we can use the requested format for the view
|
||||||
if (!textureInfo->CheckViewFormatCompatibility(desc.Format)) {
|
if (!CheckResourceViewFormatCompatibility(pResource, desc.Format)) {
|
||||||
Logger::err(str::format("D3D11: Incompatible RTV formats",
|
Logger::err(str::format("D3D11: Incompatible RTV format: ", desc.Format));
|
||||||
"\n Base format: ", textureInfo->Desc()->Format,
|
|
||||||
"\n View format: ", desc.Format));
|
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve the image that we are going to create the view for
|
||||||
|
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
|
|
||||||
// Fill in Vulkan image view info
|
// Fill in Vulkan image view info
|
||||||
DxvkImageViewCreateInfo viewInfo;
|
DxvkImageViewCreateInfo viewInfo;
|
||||||
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DXGI_VK_FORMAT_MODE_COLOR).Format;
|
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DXGI_VK_FORMAT_MODE_COLOR).Format;
|
||||||
@ -827,22 +815,21 @@ namespace dxvk {
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the image that we are going to create the view for
|
// Check whether DSVs are supported for the resource at all
|
||||||
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
if (!CheckResourceBindFlags(pResource, D3D11_BIND_DEPTH_STENCIL)) {
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether we can use the requested format for the view
|
// Check whether we can use the requested format for the view
|
||||||
if (!textureInfo->CheckViewFormatCompatibility(desc.Format)) {
|
if (!CheckResourceViewFormatCompatibility(pResource, desc.Format)) {
|
||||||
Logger::err(str::format("D3D11: Incompatible DSV formats",
|
Logger::err(str::format("D3D11: Incompatible DSV format: ", desc.Format));
|
||||||
"\n Base format: ", textureInfo->Desc()->Format,
|
|
||||||
"\n View format: ", desc.Format));
|
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve the image that we are going to create the view for
|
||||||
|
const D3D11CommonTexture* textureInfo = GetCommonTexture(pResource);
|
||||||
|
|
||||||
// Fill in Vulkan image view info
|
// Fill in Vulkan image view info
|
||||||
DxvkImageViewCreateInfo viewInfo;
|
DxvkImageViewCreateInfo viewInfo;
|
||||||
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DXGI_VK_FORMAT_MODE_DEPTH).Format;
|
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DXGI_VK_FORMAT_MODE_DEPTH).Format;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user