[PATCH v2 1/6] d3d11/tests: Added another tests for multisample resolve.

Henri Verbeet hverbeet at gmail.com
Wed Mar 10 09:03:40 CST 2021


On Tue, 9 Mar 2021 at 10:26, Jan Sikorski <jsikorski at codeweavers.com> wrote:
> +static BOOL compare_scolor(DWORD c1, DWORD c2, BYTE max_diff)
> +{
> +    signed char c1x = c1, c1y = (c1 >> 8), c1z = (c1 >> 16), c1w = (c1 >> 24);
> +    signed char c2x = c2, c2y = (c2 >> 8), c2z = (c2 >> 16), c2w = (c2 >> 24);
> +
> +    return compare_int(c1x, c2x, max_diff) && compare_int(c1y, c2y, max_diff)
> +            && compare_int(c1z, c2z, max_diff) && compare_int(c1w, c2w, max_diff);
> +}
> +
Truncating to a signed integer type is implementation-defined.

> +static void test_multisample_resolve_blended(void)
> +{
> +    static const D3D11_VIEWPORT viewport = { 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f };
> +    static const float clear_color[4] = {0.2f, 0.2f, 0.2f, 1.0f};
> +    unsigned int vertex_buffer_stride = 6 * sizeof(float);
> +    ID3D11PixelShader *pixel_shader, *pixel_shader_uint;
> +    ID3D11Texture2D *resolve_target, *render_target;
> +    D3D11_RENDER_TARGET_VIEW_DESC render_view_desc;
> +    ID3D11RenderTargetView *render_target_view;
> +    unsigned int vertex_buffer_offset = 0;
> +    ID3D11DeviceContext *device_context;
> +    D3D11_TEXTURE2D_DESC texture_desc;
> +    ID3D11VertexShader *vertex_shader;
> +    ID3D11InputLayout *input_layout;
> +    unsigned int i, quality_levels;
> +    struct resource_readback rb;
> +    ID3D11Buffer *vertex_buffer;
> +    unsigned char *result;
> +    ID3D11Device *device;
> +    BOOL compare_ok;
> +    HRESULT hr;
> +
> +    static const DWORD vs_code[] =
> +    {
> +#if 0
> +        struct VS_Input
> +        {
> +            float2 pos : TEXCOORD0;
> +            float4 color : COLOR;
> +        };
> +
> +        struct VS_Output
> +        {
> +            float4 position : SV_POSITION;
> +            float4 color : COLOR;
> +        };
> +
> +        VS_Output vs_main(VS_Input input)
> +        {
> +            VS_Output output;
> +            output.position = float4(input.pos, 0.0f, 1.0f);
> +            output.color = input.color;
> +
> +            return output;
> +        }
> +#endif
> +        0x43425844, 0x3fbe97c7, 0x2cdce39d, 0xa8d3bf48, 0xe0d872e3, 0x00000001, 0x00000160, 0x00000003,
> +        0x0000002c, 0x0000007c, 0x000000d0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
> +        0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x00000041, 0x00000000, 0x00000000,
> +        0x00000003, 0x00000001, 0x00000f0f, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
> +        0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
> +        0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x505f5653,
> +        0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000088, 0x00010040, 0x00000022,
> +        0x0300005f, 0x00101032, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067, 0x001020f2,
> +        0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x00102032, 0x00000000,
> +        0x00101046, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, 0x00004002, 0x00000000, 0x00000000,
> +        0x00000000, 0x3f800000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
> +    };
> +
> +    static const DWORD ps_code[] =
> +    {
> +#if 0
> +        float4 ps_main(VS_Output input) : SV_TARGET
> +        {
> +            return input.color;
> +        }
> +#endif
> +        0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
> +        0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
> +        0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
> +        0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
> +        0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
> +        0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
> +        0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
> +        0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e
> +    };
> +
> +    static const DWORD ps_uint_code[] =
> +    {
> +#if 0
> +        uint4 ps_main_uint(VS_Output input) : SV_TARGET
> +        {
> +            return 255 * input.color;
> +        }
> +#endif
> +        0x43425844, 0x9c2c834b, 0x37ca7b30, 0x01b4b43e, 0x713b001e, 0x00000001, 0x00000124, 0x00000003,
> +        0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
> +        0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
> +        0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
> +        0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001,
> +        0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000068, 0x00000040,
> +        0x0000001a, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
> +        0x00000001, 0x0a000038, 0x001000f2, 0x00000000, 0x00101e46, 0x00000001, 0x00004002, 0x437f0000,
> +        0x437f0000, 0x437f0000, 0x437f0000, 0x0500001c, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
> +        0x0100003e
> +    };
> +
> +    static const struct
> +    {
> +        struct vec2 xy;
> +        struct vec4 rgba;
> +    }
> +    vertex_data[] =
> +    {
> +        {{ 1.0f,  1.0f }, { .8f, 0.f, 0.f, 1.f }},
> +        {{ 1.0f, -1.0f }, { .8f, 0.f, 0.f, 1.f }},
> +        {{-1.0f, -1.0f }, { .8f, 0.f, 0.f, 1.f }},
> +    };
> +
> +    static const D3D11_INPUT_ELEMENT_DESC input_elements[] =
> +    {
> +        { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
> +        { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
> +    };
> +
Do we really need all that? It seems that most of the reason for not
using draw_color_quad() is that you're drawing a triangle over half a
pixel, in order to get partial coverage for testing how the resolve
operation blends. If that's the case, it would seem simpler (and more
robust) to pass an appropriate sample mask to OMSetBlendState()
instead. That would also allow you to trivially integrate this with
the existing test_multisample_resolve() test.

> +    static const struct
> +    {
> +        BOOL use_uint_shader;
> +        DXGI_FORMAT render_target_view_format;
> +        DXGI_FORMAT source_format;
> +        DXGI_FORMAT destination_format;
> +        DXGI_FORMAT resolve_format;
> +        unsigned int byte_count;
> +        unsigned char expected[4];
> +        BOOL todo;
> +    }
> +    tests[] =
> +    {
> +        { FALSE, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT,
> +            DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT,
> +            4, { 0, 0, 0, 0x3f } },
It's perhaps somewhat moot in light of the comment above, but at least
personally, I think "0x3f000000" is much more recognisable as "0.5f"
than the "{0, 0, 0, 0x3f}" above.

> +        ok(compare_ok, "Test %3u: expected: %2x %2x %2x %2x, got: %2x %2x %2x %2x.\n", i,
> +                tests[i].expected[0], tests[i].expected[1], tests[i].expected[2], tests[i].expected[3],
> +                result[0], result[1], result[2], result[3]);
> +
Likewise.



More information about the wine-devel mailing list