[PATCH 6/6] d3d11/tests: Add tests for constant buffer offsetting.

Henri Verbeet hverbeet at gmail.com
Thu Jul 8 08:33:03 CDT 2021


On Thu, 8 Jul 2021 at 01:13, Zebediah Figura <zfigura at codeweavers.com> wrote:
> +static void test_constant_buffer_offset(void)
> +{
> +    static const float black[] = {0.0f, 0.0f, 0.0f, 1.0f};
> +    ID3D11Buffer *buffers[2], *ret_buffers[2];
> +    struct d3d11_test_context test_context;
> +    ID3D11DeviceContext1 *context;
> +    float buffer_data[128] = {0};

"struct vec4 buffer_data[32]" would arguably make the test slightly clearer.

> +    if (FAILED(ID3D11DeviceContext_QueryInterface(test_context.immediate_context,
> +            &IID_ID3D11DeviceContext1, (void **)&context)))
> +    {
> +        skip("ID3D11Device1 is not available.\n");

"ID3D11DeviceContext1", technically.

> +    buffer_data[0] = 0.1f;
> +    buffer_data[1] = 0.2f;
> +    buffer_data[64] = 0.3f;
> +    buffer_data[65] = 0.4f;
> +    buffers[0] = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, 512, buffer_data);
> +    buffer_data[0] = 0.5f;
> +    buffer_data[1] = 0.6f;
> +    buffer_data[64] = 0.7f;
> +    buffer_data[65] = 0.8f;
> +    buffers[1] = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, 512, buffer_data);
> +
512, aka "sizeof(buffer_data)"

> +    ID3D11DeviceContext1_PSGetConstantBuffers1(context, 1, 2, ret_buffers, offsets, counts);
> +    ok(ret_buffers[0] == buffers[0], "Got buffer %p.\n", ret_buffers[0]);
> +    ok(ret_buffers[1] == buffers[1], "Got buffer %p.\n", ret_buffers[1]);
> +    ok(offsets[0] == 0, "Got offset %u.\n", offsets[0]);
> +    ok(offsets[1] == 16, "Got offset %u.\n", offsets[1]);
> +    ok(counts[0] == 16, "Got count %u.\n", counts[0]);
> +    ok(counts[1] == 16, "Got count %u.\n", counts[1]);
> +    ID3D11Buffer_Release(ret_buffers[0]);
> +    ID3D11Buffer_Release(ret_buffers[1]);
> +
> +    ID3D11DeviceContext1_PSSetConstantBuffers1(context, 1, 2, buffers, offsets, NULL);
> +
> +    ID3D11DeviceContext1_PSGetConstantBuffers1(context, 1, 2, ret_buffers, offsets, counts);
> +    ok(ret_buffers[0] == buffers[0], "Got buffer %p.\n", ret_buffers[0]);
> +    ok(ret_buffers[1] == buffers[1], "Got buffer %p.\n", ret_buffers[1]);
> +    ok(offsets[0] == 0, "Got offset %u.\n", offsets[0]);
> +    ok(offsets[1] == 16, "Got offset %u.\n", offsets[1]);
> +    ok(counts[0] == 16, "Got count %u.\n", counts[0]);
> +    ok(counts[1] == 16, "Got count %u.\n", counts[1]);
> +    ID3D11Buffer_Release(ret_buffers[0]);
> +    ID3D11Buffer_Release(ret_buffers[1]);
> +
That's perhaps a little ambiguous; was the call ignored, or did it
"update" only the offsets?

> +    counts[0] = 16;
> +    counts[1] = 16;
> +    ID3D11DeviceContext1_PSSetConstantBuffers1(context, 1, 2, buffers, NULL, counts);
> +
> +    ID3D11DeviceContext1_PSGetConstantBuffers1(context, 1, 2, ret_buffers, offsets, counts);
> +    ok(ret_buffers[0] == buffers[0], "Got buffer %p.\n", ret_buffers[0]);
> +    ok(ret_buffers[1] == buffers[1], "Got buffer %p.\n", ret_buffers[1]);
> +    ok(offsets[0] == 0, "Got offset %u.\n", offsets[0]);
> +    ok(offsets[1] == 16, "Got offset %u.\n", offsets[1]);
> +    ok(counts[0] == 16, "Got count %u.\n", counts[0]);
> +    ok(counts[1] == 16, "Got count %u.\n", counts[1]);
> +    ID3D11Buffer_Release(ret_buffers[0]);
> +    ID3D11Buffer_Release(ret_buffers[1]);
> +
Likewise, but for the counts.



More information about the wine-devel mailing list