mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[d3d11] Allow creation of SRGB textures with D3D11_BIND_UNORDERED_ACCESS
Should fix a crash in Call of Duty: Advanced Warfare.
This commit is contained in:
parent
24dd173d12
commit
73c91138db
@ -49,12 +49,12 @@ namespace dxvk {
|
|||||||
// The image must be marked as mutable if it can be reinterpreted
|
// The image must be marked as mutable if it can be reinterpreted
|
||||||
// by a view with a different format. Depth-stencil formats cannot
|
// by a view with a different format. Depth-stencil formats cannot
|
||||||
// be reinterpreted in Vulkan, so we'll ignore those.
|
// be reinterpreted in Vulkan, so we'll ignore those.
|
||||||
VkImageAspectFlags formatAspect = imageFormatInfo(formatInfo.Format)->aspectMask;
|
auto formatProperties = imageFormatInfo(formatInfo.Format);
|
||||||
|
|
||||||
bool isTypeless = formatInfo.Aspect == 0;
|
bool isTypeless = formatInfo.Aspect == 0;
|
||||||
bool isMutable = formatFamily.FormatCount > 1;
|
bool isMutable = formatFamily.FormatCount > 1;
|
||||||
|
|
||||||
if (isMutable && (formatAspect & VK_IMAGE_ASPECT_COLOR_BIT)) {
|
if (isMutable && (formatProperties->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT)) {
|
||||||
imageInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
|
imageInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
|
||||||
|
|
||||||
// Typeless UAV images have relaxed reinterpretation rules
|
// Typeless UAV images have relaxed reinterpretation rules
|
||||||
@ -64,6 +64,12 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some games will try to create an SRGB image with the UAV
|
||||||
|
// bind flag set. This works on Windows, but no UAVs can be
|
||||||
|
// created for the image in practice.
|
||||||
|
bool noUav = formatProperties->flags.test(DxvkFormatFlag::ColorSpaceSrgb)
|
||||||
|
&& !CheckFormatFeatureSupport(formatInfo.Format, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT);
|
||||||
|
|
||||||
// Adjust image flags based on the corresponding D3D flags
|
// Adjust image flags based on the corresponding D3D flags
|
||||||
if (m_desc.BindFlags & D3D11_BIND_SHADER_RESOURCE) {
|
if (m_desc.BindFlags & D3D11_BIND_SHADER_RESOURCE) {
|
||||||
imageInfo.usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
imageInfo.usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
@ -86,7 +92,7 @@ namespace dxvk {
|
|||||||
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS) {
|
if (m_desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS && !noUav) {
|
||||||
imageInfo.usage |= VK_IMAGE_USAGE_STORAGE_BIT;
|
imageInfo.usage |= VK_IMAGE_USAGE_STORAGE_BIT;
|
||||||
imageInfo.stages |= pDevice->GetEnabledShaderStages();
|
imageInfo.stages |= pDevice->GetEnabledShaderStages();
|
||||||
imageInfo.access |= VK_ACCESS_SHADER_READ_BIT
|
imageInfo.access |= VK_ACCESS_SHADER_READ_BIT
|
||||||
@ -264,6 +270,16 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL D3D11CommonTexture::CheckFormatFeatureSupport(
|
||||||
|
VkFormat Format,
|
||||||
|
VkFormatFeatureFlags Features) const {
|
||||||
|
VkFormatProperties properties = m_device->GetDXVKDevice()->adapter()->formatProperties(Format);
|
||||||
|
|
||||||
|
return (properties.linearTilingFeatures & Features) == Features
|
||||||
|
|| (properties.optimalTilingFeatures & Features) == Features;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
D3D11_COMMON_TEXTURE_MAP_MODE D3D11CommonTexture::DetermineMapMode(
|
D3D11_COMMON_TEXTURE_MAP_MODE D3D11CommonTexture::DetermineMapMode(
|
||||||
const DxvkImageCreateInfo* pImageInfo) const {
|
const DxvkImageCreateInfo* pImageInfo) const {
|
||||||
// Don't map an image unless the application requests it
|
// Don't map an image unless the application requests it
|
||||||
|
@ -189,6 +189,10 @@ namespace dxvk {
|
|||||||
const DxvkImageCreateInfo* pImageInfo,
|
const DxvkImageCreateInfo* pImageInfo,
|
||||||
VkImageTiling Tiling) const;
|
VkImageTiling Tiling) const;
|
||||||
|
|
||||||
|
BOOL CheckFormatFeatureSupport(
|
||||||
|
VkFormat Format,
|
||||||
|
VkImageUsageFlags Features) const;
|
||||||
|
|
||||||
D3D11_COMMON_TEXTURE_MAP_MODE DetermineMapMode(
|
D3D11_COMMON_TEXTURE_MAP_MODE DetermineMapMode(
|
||||||
const DxvkImageCreateInfo* pImageInfo) const;
|
const DxvkImageCreateInfo* pImageInfo) const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user