1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-29 17:52:18 +01:00

[d3d11] Do not create views if the resource bind flags are invalid

This commit is contained in:
Philip Rebohle 2018-02-22 21:38:45 +01:00
parent 4c693fc262
commit 2b9ab6626a
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 42 additions and 0 deletions

View File

@ -162,6 +162,11 @@ namespace dxvk {
D3D11_BUFFER_DESC 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;
D3D11_BUFFEREX_SRV bufInfo;
@ -223,6 +228,11 @@ namespace dxvk {
const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pResource);
if ((textureInfo->bindFlags & D3D11_BIND_SHADER_RESOURCE) == 0) {
Logger::warn("D3D11: Trying to create SRV for texture without D3D11_BIND_SHADER_RESOURCE");
return E_INVALIDARG;
}
// Fill in the view info. The view type depends solely
// on the view dimension field in the view description,
// not on the resource type.
@ -358,6 +368,11 @@ namespace dxvk {
D3D11_BUFFER_DESC 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;
if (desc.Buffer.Flags & D3D11_BUFFEREX_SRV_FLAG_RAW) {
@ -409,6 +424,11 @@ namespace dxvk {
const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pResource);
if ((textureInfo->bindFlags & D3D11_BIND_UNORDERED_ACCESS) == 0) {
Logger::warn("D3D11: Trying to create UAV for texture without D3D11_BIND_UNORDERED_ACCESS");
return E_INVALIDARG;
}
// Fill in the view info. The view type depends solely
// on the view dimension field in the view description,
// not on the resource type.
@ -514,6 +534,11 @@ namespace dxvk {
const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pResource);
if ((textureInfo->bindFlags & D3D11_BIND_RENDER_TARGET) == 0) {
Logger::warn("D3D11: Trying to create RTV for texture without D3D11_BIND_RENDER_TARGET");
return E_INVALIDARG;
}
// Fill in Vulkan image view info
DxvkImageViewCreateInfo viewInfo;
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DxgiFormatMode::Color).format;
@ -610,6 +635,11 @@ namespace dxvk {
const D3D11TextureInfo* textureInfo
= GetCommonTextureInfo(pResource);
if ((textureInfo->bindFlags & D3D11_BIND_DEPTH_STENCIL) == 0) {
Logger::warn("D3D11: Trying to create DSV for texture without D3D11_BIND_DEPTH_STENCIL");
return E_INVALIDARG;
}
// Fill in Vulkan image view info
DxvkImageViewCreateInfo viewInfo;
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DxgiFormatMode::Depth).format;

View File

@ -205,6 +205,9 @@ namespace dxvk {
m_texInfo.imageBuffer = m_desc.CPUAccessFlags != 0
? CreateImageBuffer(pDevice->GetDXVKDevice(), info.format, info.extent)
: nullptr;
m_texInfo.usage = m_desc.Usage;
m_texInfo.bindFlags = m_desc.BindFlags;
}
///////////////////////////////////////////
@ -302,6 +305,9 @@ namespace dxvk {
m_texInfo.imageBuffer = m_desc.CPUAccessFlags != 0
? CreateImageBuffer(pDevice->GetDXVKDevice(), info.format, info.extent)
: nullptr;
m_texInfo.usage = m_desc.Usage;
m_texInfo.bindFlags = m_desc.BindFlags;
}
@ -396,6 +402,9 @@ namespace dxvk {
m_texInfo.imageBuffer = m_desc.CPUAccessFlags != 0
? CreateImageBuffer(pDevice->GetDXVKDevice(), info.format, info.extent)
: nullptr;
m_texInfo.usage = m_desc.Usage;
m_texInfo.bindFlags = m_desc.BindFlags;
}

View File

@ -20,6 +20,9 @@ namespace dxvk {
Rc<DxvkBuffer> imageBuffer;
Rc<DxvkImage> image;
D3D11_USAGE usage;
UINT bindFlags;
VkImageSubresource mappedSubresource = {
VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 };
};