mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-31 20:40:09 +01:00
dzn: Use A4B4G4R4 instead of B4G4R4A4 when available
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22911>
This commit is contained in:
parent
95df5f2e8c
commit
a4ce095bad
6 changed files with 59 additions and 43 deletions
|
|
@ -40,31 +40,6 @@ dEQP-VK.glsl.texture_functions.textureprojgradoffset.sampler2dshadow_vertex,Fail
|
|||
dEQP-VK.glsl.texture_functions.textureprojoffset.sampler1dshadow_bias_fragment,Fail
|
||||
dEQP-VK.glsl.texture_functions.textureprojoffset.sampler2dshadow_bias_fragment,Fail
|
||||
|
||||
# We need to use a format that has alpha in the right spot to be able to get the right border color here. Fix incoming,
|
||||
# needs updated WARP for correct support.
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.igba.opaque_black.gather_2.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.igba.opaque_black.gather_3.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.igba.opaque_black.no_gather.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.rgba.opaque_black.gather_2.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.rgba.opaque_black.gather_3.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.rgba.opaque_black.no_gather.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.rgbi.opaque_black.gather_2.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.rgbi.opaque_black.gather_3.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.rgbi.opaque_black.no_gather.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.rgia.opaque_black.gather_2.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.rgia.opaque_black.gather_3.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.rgia.opaque_black.no_gather.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.riba.opaque_black.gather_2.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.riba.opaque_black.gather_3.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.b4g4r4a4_unorm_pack16.riba.opaque_black.no_gather.no_swizzle_hint,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.view_type.1d.format.b4g4r4a4_unorm_pack16.address_modes.all_mode_clamp_to_border_opaque_black,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.view_type.1d_array.format.b4g4r4a4_unorm_pack16.address_modes.all_mode_clamp_to_border_opaque_black,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.view_type.1d_unnormalized.format.b4g4r4a4_unorm_pack16.address_modes.all_mode_clamp_to_border_opaque_black,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.view_type.2d.format.b4g4r4a4_unorm_pack16.address_modes.all_mode_clamp_to_border_opaque_black,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.view_type.2d_array.format.b4g4r4a4_unorm_pack16.address_modes.all_mode_clamp_to_border_opaque_black,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.view_type.2d_unnormalized.format.b4g4r4a4_unorm_pack16.address_modes.all_mode_clamp_to_border_opaque_black,Fail
|
||||
dEQP-VK.pipeline.monolithic.sampler.view_type.3d.format.b4g4r4a4_unorm_pack16.address_modes.all_mode_clamp_to_border_opaque_black,Fail
|
||||
|
||||
# WARP/DXC bug, some phi/control flow lowering caused incorrect values to be loaded after the loop.
|
||||
# Fix incoming: https://github.com/microsoft/DirectXShaderCompiler/pull/5180
|
||||
dEQP-VK.glsl.loops.generic.do_while_dynamic_iterations.basic_highp_float_fragment,Fail
|
||||
|
|
|
|||
|
|
@ -1967,15 +1967,20 @@ dzn_cmd_buffer_clear_rects_with_copy(struct dzn_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
static VkClearColorValue
|
||||
adjust_clear_color(VkFormat format, const VkClearColorValue *col)
|
||||
adjust_clear_color(struct dzn_physical_device *pdev,
|
||||
VkFormat format, const VkClearColorValue *col)
|
||||
{
|
||||
VkClearColorValue out = *col;
|
||||
|
||||
// D3D12 doesn't support bgra4, so we map it to rgba4 and swizzle things
|
||||
// manually where it matters, like here, in the clear path.
|
||||
if (format == VK_FORMAT_B4G4R4A4_UNORM_PACK16) {
|
||||
DZN_SWAP(float, out.float32[0], out.float32[1]);
|
||||
DZN_SWAP(float, out.float32[2], out.float32[3]);
|
||||
if (pdev->support_a4b4g4r4) {
|
||||
DZN_SWAP(float, out.float32[0], out.float32[2]);
|
||||
} else {
|
||||
DZN_SWAP(float, out.float32[0], out.float32[1]);
|
||||
DZN_SWAP(float, out.float32[2], out.float32[3]);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
|
|
@ -2123,6 +2128,8 @@ dzn_cmd_buffer_clear_attachment(struct dzn_cmd_buffer *cmdbuf,
|
|||
{
|
||||
struct dzn_image *image =
|
||||
container_of(view->vk.image, struct dzn_image, vk);
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(cmdbuf->vk.base.device->physical, struct dzn_physical_device, vk);
|
||||
|
||||
VkImageSubresourceRange range = {
|
||||
.aspectMask = aspects,
|
||||
|
|
@ -2176,7 +2183,7 @@ dzn_cmd_buffer_clear_attachment(struct dzn_cmd_buffer *cmdbuf,
|
|||
}
|
||||
}
|
||||
} else if (aspects & VK_IMAGE_ASPECT_COLOR_BIT) {
|
||||
VkClearColorValue color = adjust_clear_color(view->vk.format, &value->color);
|
||||
VkClearColorValue color = adjust_clear_color(pdev, view->vk.format, &value->color);
|
||||
bool clear_with_cpy = false;
|
||||
float vals[4];
|
||||
|
||||
|
|
@ -2245,13 +2252,15 @@ dzn_cmd_buffer_clear_color(struct dzn_cmd_buffer *cmdbuf,
|
|||
uint32_t range_count,
|
||||
const VkImageSubresourceRange *ranges)
|
||||
{
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(cmdbuf->vk.base.device->physical, struct dzn_physical_device, vk);
|
||||
if (!(image->desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET) ||
|
||||
cmdbuf->type != D3D12_COMMAND_LIST_TYPE_DIRECT) {
|
||||
dzn_cmd_buffer_clear_ranges_with_copy(cmdbuf, image, layout, col, range_count, ranges);
|
||||
return;
|
||||
}
|
||||
|
||||
VkClearColorValue color = adjust_clear_color(image->vk.format, col);
|
||||
VkClearColorValue color = adjust_clear_color(pdev, image->vk.format, col);
|
||||
float clear_vals[4];
|
||||
|
||||
enum pipe_format pfmt = vk_format_to_pipe_format(image->vk.format);
|
||||
|
|
|
|||
|
|
@ -475,6 +475,13 @@ dzn_physical_device_cache_caps(struct dzn_physical_device *pdev)
|
|||
pdev->options19.MaxSamplerDescriptorHeapSizeWithStaticSamplers = pdev->options19.MaxSamplerDescriptorHeapSize;
|
||||
pdev->options19.MaxViewDescriptorHeapSize = D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1;
|
||||
}
|
||||
{
|
||||
D3D12_FEATURE_DATA_FORMAT_SUPPORT a4b4g4r4_support = {
|
||||
.Format = DXGI_FORMAT_A4B4G4R4_UNORM
|
||||
};
|
||||
pdev->support_a4b4g4r4 =
|
||||
SUCCEEDED(ID3D12Device1_CheckFeatureSupport(pdev->dev, D3D12_FEATURE_FORMAT_SUPPORT, &a4b4g4r4_support, sizeof(a4b4g4r4_support)));
|
||||
}
|
||||
|
||||
pdev->queue_families[pdev->queue_family_count++] = (struct dzn_queue_family) {
|
||||
.props = {
|
||||
|
|
@ -856,10 +863,16 @@ dzn_physical_device_get_format_properties(struct dzn_physical_device *pdev,
|
|||
}
|
||||
}
|
||||
|
||||
/* B4G4R4A4 support is required, but d3d12 doesn't support it. We map this
|
||||
* format to R4G4B4A4 and adjust the SRV component-mapping to fake
|
||||
/* B4G4R4A4 support is required, but d3d12 doesn't support it. The needed
|
||||
* d3d12 format would be A4R4G4B4. We map this format to d3d12's B4G4R4A4,
|
||||
* which is Vulkan's A4R4G4B4, and adjust the SRV component-mapping to fake
|
||||
* B4G4R4A4, but that forces us to limit the usage to sampling, which,
|
||||
* luckily, is exactly what we need to support the required features.
|
||||
*
|
||||
* However, since this involves swizzling the alpha channel, it can cause
|
||||
* problems for border colors. Fortunately, d3d12 added an A4B4G4R4 format,
|
||||
* which still isn't quite right (it'd be Vulkan R4G4B4A4), but can be
|
||||
* swizzled by just swapping R and B, so no border color issues arise.
|
||||
*/
|
||||
if (format == VK_FORMAT_B4G4R4A4_UNORM_PACK16) {
|
||||
VkFormatFeatureFlags bgra4_req_features =
|
||||
|
|
|
|||
|
|
@ -276,6 +276,9 @@ dzn_image_get_dxgi_format(const struct dzn_physical_device *pdev,
|
|||
{
|
||||
enum pipe_format pfmt = vk_format_to_pipe_format(format);
|
||||
|
||||
if (pfmt == PIPE_FORMAT_A4R4G4B4_UNORM && !pdev->support_a4b4g4r4)
|
||||
return DXGI_FORMAT_B4G4R4A4_UNORM;
|
||||
|
||||
if (!vk_format_is_depth_or_stencil(format))
|
||||
return dzn_pipe_to_dxgi_format(pfmt);
|
||||
|
||||
|
|
@ -1043,17 +1046,31 @@ dzn_image_view_prepare_srv_desc(struct dzn_image_view *iview)
|
|||
|
||||
/* Swap components to fake B4G4R4A4 support. */
|
||||
if (iview->vk.format == VK_FORMAT_B4G4R4A4_UNORM_PACK16) {
|
||||
static const D3D12_SHADER_COMPONENT_MAPPING bgra4_remap[] = {
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1,
|
||||
};
|
||||
if (pdev->support_a4b4g4r4) {
|
||||
static const D3D12_SHADER_COMPONENT_MAPPING bgra4_remap[] = {
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1,
|
||||
};
|
||||
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(swz); i++)
|
||||
swz[i] = bgra4_remap[swz[i]];
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(swz); i++)
|
||||
swz[i] = bgra4_remap[swz[i]];
|
||||
} else {
|
||||
static const D3D12_SHADER_COMPONENT_MAPPING bgra4_remap[] = {
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1,
|
||||
};
|
||||
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(swz); i++)
|
||||
swz[i] = bgra4_remap[swz[i]];
|
||||
}
|
||||
} else if (iview->vk.aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
|
||||
/* D3D puts stencil in G, not R. Requests for R should be routed to G and vice versa. */
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(swz); i++) {
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ struct dzn_physical_device {
|
|||
D3D12_HEAP_FLAGS heap_flags_for_mem_type[VK_MAX_MEMORY_TYPES];
|
||||
const struct vk_sync_type *sync_types[MAX_SYNC_TYPES + 1];
|
||||
float timestamp_period;
|
||||
bool support_a4b4g4r4;
|
||||
};
|
||||
|
||||
D3D12_FEATURE_DATA_FORMAT_SUPPORT
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ static const DXGI_FORMAT formats[PIPE_FORMAT_COUNT] = {
|
|||
[PIPE_FORMAT_B8G8R8X8_UNORM] = DXGI_FORMAT_B8G8R8X8_UNORM,
|
||||
[PIPE_FORMAT_B8G8R8A8_UNORM] = DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
[PIPE_FORMAT_B4G4R4A4_UNORM] = DXGI_FORMAT_B4G4R4A4_UNORM,
|
||||
[PIPE_FORMAT_A4R4G4B4_UNORM] = DXGI_FORMAT_B4G4R4A4_UNORM,
|
||||
[PIPE_FORMAT_A4R4G4B4_UNORM] = DXGI_FORMAT_A4B4G4R4_UNORM,
|
||||
[PIPE_FORMAT_A4B4G4R4_UNORM] = DXGI_FORMAT_A4B4G4R4_UNORM,
|
||||
[PIPE_FORMAT_B5G6R5_UNORM] = DXGI_FORMAT_B5G6R5_UNORM,
|
||||
[PIPE_FORMAT_B5G5R5A1_UNORM] = DXGI_FORMAT_B5G5R5A1_UNORM,
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue