tests/shader_runner: Factor out a resource_desc structure.

This commit is contained in:
Elizabeth Figura 2024-06-17 16:01:04 -05:00 committed by Henri Verbeet
parent fa570ee1f3
commit fe21318b5f
Notes: Henri Verbeet 2024-07-11 00:41:24 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/924
7 changed files with 308 additions and 311 deletions

View File

@ -496,44 +496,46 @@ static void parse_resource_directive(struct resource_params *resource, const cha
{
if (match_string(line, "format", &line))
{
resource->format = parse_format(line, &resource->data_type, &resource->texel_size, &resource->is_shadow, &line);
resource->desc.format = parse_format(line, &resource->data_type,
&resource->desc.texel_size, &resource->is_shadow, &line);
}
else if (match_string(line, "stride", &line))
{
if (sscanf(line, "%u", &resource->stride) < 1)
fatal_error("Malformed texture stride '%s'.\n", line);
resource->texel_size = resource->stride;
resource->format = DXGI_FORMAT_UNKNOWN;
resource->desc.texel_size = resource->stride;
resource->desc.format = DXGI_FORMAT_UNKNOWN;
}
else if (match_string(line, "size", &line))
{
if (sscanf(line, "( buffer , %u ) ", &resource->width) == 1)
if (sscanf(line, "( buffer , %u ) ", &resource->desc.width) == 1)
{
resource->dimension = RESOURCE_DIMENSION_BUFFER;
resource->height = 1;
resource->desc.dimension = RESOURCE_DIMENSION_BUFFER;
resource->desc.height = 1;
}
else if (sscanf(line, "( raw_buffer , %u ) ", &resource->width) == 1)
else if (sscanf(line, "( raw_buffer , %u ) ", &resource->desc.width) == 1)
{
resource->dimension = RESOURCE_DIMENSION_BUFFER;
resource->height = 1;
resource->desc.dimension = RESOURCE_DIMENSION_BUFFER;
resource->desc.height = 1;
resource->is_raw = true;
}
else if (sscanf(line, "( counter_buffer , %u ) ", &resource->width) == 1)
else if (sscanf(line, "( counter_buffer , %u ) ", &resource->desc.width) == 1)
{
resource->dimension = RESOURCE_DIMENSION_BUFFER;
resource->height = 1;
resource->desc.dimension = RESOURCE_DIMENSION_BUFFER;
resource->desc.height = 1;
resource->is_uav_counter = true;
resource->stride = sizeof(uint32_t);
resource->texel_size = resource->stride;
resource->format = DXGI_FORMAT_UNKNOWN;
resource->desc.texel_size = resource->stride;
resource->desc.format = DXGI_FORMAT_UNKNOWN;
}
else if (sscanf(line, "( 2d , %u , %u ) ", &resource->width, &resource->height) == 2)
else if (sscanf(line, "( 2d , %u , %u ) ", &resource->desc.width, &resource->desc.height) == 2)
{
resource->dimension = RESOURCE_DIMENSION_2D;
resource->desc.dimension = RESOURCE_DIMENSION_2D;
}
else if (sscanf(line, "( 2dms , %u , %u , %u ) ", &resource->sample_count, &resource->width, &resource->height) == 3)
else if (sscanf(line, "( 2dms , %u , %u , %u ) ",
&resource->desc.sample_count, &resource->desc.width, &resource->desc.height) == 3)
{
resource->dimension = RESOURCE_DIMENSION_2D;
resource->desc.dimension = RESOURCE_DIMENSION_2D;
}
else
{
@ -544,7 +546,7 @@ static void parse_resource_directive(struct resource_params *resource, const cha
{
char *rest;
resource->level_count = strtoul(line, &rest, 10);
resource->desc.level_count = strtoul(line, &rest, 10);
if (rest == line)
fatal_error("Malformed texture directive '%s'.\n", line);
}
@ -618,14 +620,7 @@ static void parse_input_layout_directive(struct shader_runner *runner, const cha
void init_resource(struct resource *resource, const struct resource_params *params)
{
resource->type = params->type;
resource->dimension = params->dimension;
resource->slot = params->slot;
resource->format = params->format;
resource->texel_size = params->texel_size;
resource->width = params->width;
resource->height = params->height;
resource->sample_count = params->sample_count;
resource->desc = params->desc;
}
struct resource *shader_runner_get_resource(struct shader_runner *runner, enum resource_type type, unsigned int slot)
@ -637,7 +632,7 @@ struct resource *shader_runner_get_resource(struct shader_runner *runner, enum r
{
resource = runner->resources[i];
if (resource->type == type && resource->slot == slot)
if (resource->desc.type == type && resource->desc.slot == slot)
return resource;
}
@ -657,24 +652,25 @@ static void set_resource(struct shader_runner *runner, const struct resource_par
if (!(resource = runner->ops->create_resource(runner, params)))
{
if (!bitmap_is_set(runner->failed_resources[params->type], params->slot))
if (!bitmap_is_set(runner->failed_resources[params->desc.type], params->desc.slot))
{
++runner->failed_resource_count;
bitmap_set(runner->failed_resources[params->type], params->slot);
bitmap_set(runner->failed_resources[params->desc.type], params->desc.slot);
}
return;
}
if (bitmap_is_set(runner->failed_resources[params->type], params->slot))
if (bitmap_is_set(runner->failed_resources[params->desc.type], params->desc.slot))
{
assert(runner->failed_resource_count);
--runner->failed_resource_count;
bitmap_clear(runner->failed_resources[params->type], params->slot);
bitmap_clear(runner->failed_resources[params->desc.type], params->desc.slot);
}
for (i = 0; i < runner->resource_count; ++i)
{
if (runner->resources[i]->slot == resource->slot && runner->resources[i]->type == resource->type)
if (runner->resources[i]->desc.slot == resource->desc.slot
&& runner->resources[i]->desc.type == resource->desc.type)
{
runner->ops->destroy_resource(runner, runner->resources[i]);
runner->resources[i] = resource;
@ -903,15 +899,15 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
if (!shader_runner_has_target(runner))
{
memset(&params, 0, sizeof(params));
params.slot = 0;
params.type = RESOURCE_TYPE_RENDER_TARGET;
params.dimension = RESOURCE_DIMENSION_2D;
params.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
params.desc.slot = 0;
params.desc.type = RESOURCE_TYPE_RENDER_TARGET;
params.desc.dimension = RESOURCE_DIMENSION_2D;
params.desc.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
params.data_type = TEXTURE_DATA_FLOAT;
params.texel_size = 16;
params.width = RENDER_TARGET_WIDTH;
params.height = RENDER_TARGET_HEIGHT;
params.level_count = 1;
params.desc.texel_size = 16;
params.desc.width = RENDER_TARGET_WIDTH;
params.desc.height = RENDER_TARGET_HEIGHT;
params.desc.level_count = 1;
set_resource(runner, &params);
}
@ -930,10 +926,10 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
runner->input_element_count = 1;
memset(&params, 0, sizeof(params));
params.slot = 0;
params.type = RESOURCE_TYPE_VERTEX_BUFFER;
params.dimension = RESOURCE_DIMENSION_BUFFER;
params.width = sizeof(quad);
params.desc.slot = 0;
params.desc.type = RESOURCE_TYPE_VERTEX_BUFFER;
params.desc.dimension = RESOURCE_DIMENSION_BUFFER;
params.desc.width = sizeof(quad);
params.data = malloc(sizeof(quad));
memcpy(params.data, quad, sizeof(quad));
params.data_size = sizeof(quad);
@ -957,15 +953,15 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
if (!shader_runner_has_target(runner))
{
memset(&params, 0, sizeof(params));
params.slot = 0;
params.type = RESOURCE_TYPE_RENDER_TARGET;
params.dimension = RESOURCE_DIMENSION_2D;
params.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
params.desc.slot = 0;
params.desc.type = RESOURCE_TYPE_RENDER_TARGET;
params.desc.dimension = RESOURCE_DIMENSION_2D;
params.desc.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
params.data_type = TEXTURE_DATA_FLOAT;
params.texel_size = 16;
params.width = RENDER_TARGET_WIDTH;
params.height = RENDER_TARGET_HEIGHT;
params.level_count = 1;
params.desc.texel_size = 16;
params.desc.width = RENDER_TARGET_WIDTH;
params.desc.height = RENDER_TARGET_HEIGHT;
params.desc.level_count = 1;
set_resource(runner, &params);
}
@ -1671,8 +1667,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
break;
case STATE_RESOURCE:
if (current_resource.type == RESOURCE_TYPE_VERTEX_BUFFER)
current_resource.width = current_resource.data_size;
if (current_resource.desc.type == RESOURCE_TYPE_VERTEX_BUFFER)
current_resource.desc.width = current_resource.data_size;
/* Not every backend supports every resource type
* (specifically, D3D9 doesn't support UAVs and
@ -1907,12 +1903,12 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
memset(&current_resource, 0, sizeof(current_resource));
current_resource.slot = index;
current_resource.type = RESOURCE_TYPE_RENDER_TARGET;
current_resource.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
current_resource.desc.slot = index;
current_resource.desc.type = RESOURCE_TYPE_RENDER_TARGET;
current_resource.desc.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
current_resource.data_type = TEXTURE_DATA_FLOAT;
current_resource.texel_size = 16;
current_resource.level_count = 1;
current_resource.desc.texel_size = 16;
current_resource.desc.level_count = 1;
}
else if (!strcmp(line, "[dsv]\n"))
{
@ -1920,13 +1916,13 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
memset(&current_resource, 0, sizeof(current_resource));
current_resource.slot = 0;
current_resource.type = RESOURCE_TYPE_DEPTH_STENCIL;
current_resource.format = DXGI_FORMAT_D32_FLOAT;
current_resource.desc.slot = 0;
current_resource.desc.type = RESOURCE_TYPE_DEPTH_STENCIL;
current_resource.desc.format = DXGI_FORMAT_D32_FLOAT;
current_resource.is_shadow = true;
current_resource.data_type = TEXTURE_DATA_FLOAT;
current_resource.texel_size = 4;
current_resource.level_count = 1;
current_resource.desc.texel_size = 4;
current_resource.desc.level_count = 1;
}
else if (sscanf(line, "[srv %u]\n", &index))
{
@ -1934,12 +1930,12 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
memset(&current_resource, 0, sizeof(current_resource));
current_resource.slot = index;
current_resource.type = RESOURCE_TYPE_TEXTURE;
current_resource.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
current_resource.desc.slot = index;
current_resource.desc.type = RESOURCE_TYPE_TEXTURE;
current_resource.desc.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
current_resource.data_type = TEXTURE_DATA_FLOAT;
current_resource.texel_size = 16;
current_resource.level_count = 1;
current_resource.desc.texel_size = 16;
current_resource.desc.level_count = 1;
}
else if (sscanf(line, "[uav %u]\n", &index))
{
@ -1947,12 +1943,12 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
memset(&current_resource, 0, sizeof(current_resource));
current_resource.slot = index;
current_resource.type = RESOURCE_TYPE_UAV;
current_resource.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
current_resource.desc.slot = index;
current_resource.desc.type = RESOURCE_TYPE_UAV;
current_resource.desc.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
current_resource.data_type = TEXTURE_DATA_FLOAT;
current_resource.texel_size = 16;
current_resource.level_count = 1;
current_resource.desc.texel_size = 16;
current_resource.desc.level_count = 1;
}
else if (sscanf(line, "[vb %u]\n", &index))
{
@ -1960,9 +1956,9 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
memset(&current_resource, 0, sizeof(current_resource));
current_resource.slot = index;
current_resource.type = RESOURCE_TYPE_VERTEX_BUFFER;
current_resource.dimension = RESOURCE_DIMENSION_BUFFER;
current_resource.desc.slot = index;
current_resource.desc.type = RESOURCE_TYPE_VERTEX_BUFFER;
current_resource.desc.dimension = RESOURCE_DIMENSION_BUFFER;
current_resource.data_type = TEXTURE_DATA_FLOAT;
}
else if (!strcmp(line, "[test]\n"))

View File

@ -84,36 +84,36 @@ enum resource_dimension
RESOURCE_DIMENSION_2D,
};
struct resource_params
struct resource_desc
{
unsigned int slot;
enum resource_type type;
enum resource_dimension dimension;
DXGI_FORMAT format;
unsigned int texel_size;
unsigned int width, height;
unsigned int level_count;
unsigned int sample_count;
};
struct resource_params
{
struct resource_desc desc;
bool is_shadow;
bool is_raw;
bool is_uav_counter;
enum texture_data_type data_type;
unsigned int texel_size;
unsigned int stride;
unsigned int width, height;
unsigned int level_count;
unsigned int sample_count;
uint8_t *data;
size_t data_size, data_capacity;
};
struct resource
{
unsigned int slot;
enum resource_type type;
enum resource_dimension dimension;
DXGI_FORMAT format;
unsigned int texel_size;
unsigned int width, height;
unsigned int sample_count;
struct resource_desc desc;
};
struct input_element

View File

@ -370,34 +370,35 @@ static bool init_resource_2d(struct d3d11_shader_runner *runner, struct d3d11_re
UINT quality_levels;
HRESULT hr;
if (params->level_count > ARRAY_SIZE(resource_data))
fatal_error("Level count %u is too high.\n", params->level_count);
if (params->desc.level_count > ARRAY_SIZE(resource_data))
fatal_error("Level count %u is too high.\n", params->desc.level_count);
if (params->sample_count > 1)
if (params->desc.sample_count > 1)
{
if (params->level_count > 1)
if (params->desc.level_count > 1)
fatal_error("Multisampled texture has multiple levels.\n");
if (FAILED(ID3D11Device_CheckMultisampleQualityLevels(device,
params->format, params->sample_count, &quality_levels)) || !quality_levels)
params->desc.format, params->desc.sample_count, &quality_levels)) || !quality_levels)
{
trace("Format #%x with sample count %u is not supported; skipping.\n", params->format, params->sample_count);
trace("Format #%x with sample count %u is not supported; skipping.\n",
params->desc.format, params->desc.sample_count);
return false;
}
}
desc.Width = params->width;
desc.Height = params->height;
desc.MipLevels = params->level_count;
desc.Width = params->desc.width;
desc.Height = params->desc.height;
desc.MipLevels = params->desc.level_count;
desc.ArraySize = 1;
desc.Format = params->format;
desc.SampleDesc.Count = max(params->sample_count, 1);
desc.Format = params->desc.format;
desc.SampleDesc.Count = max(params->desc.sample_count, 1);
desc.Usage = D3D11_USAGE_DEFAULT;
if (params->type == RESOURCE_TYPE_UAV)
if (params->desc.type == RESOURCE_TYPE_UAV)
desc.BindFlags = D3D11_BIND_UNORDERED_ACCESS;
else if (params->type == RESOURCE_TYPE_RENDER_TARGET)
else if (params->desc.type == RESOURCE_TYPE_RENDER_TARGET)
desc.BindFlags = D3D11_BIND_RENDER_TARGET;
else if (params->type == RESOURCE_TYPE_DEPTH_STENCIL)
else if (params->desc.type == RESOURCE_TYPE_DEPTH_STENCIL)
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
else
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
@ -406,16 +407,16 @@ static bool init_resource_2d(struct d3d11_shader_runner *runner, struct d3d11_re
{
unsigned int buffer_offset = 0;
if (params->sample_count > 1)
if (params->desc.sample_count > 1)
fatal_error("Cannot upload data to a multisampled texture.\n");
for (unsigned int level = 0; level < params->level_count; ++level)
for (unsigned int level = 0; level < params->desc.level_count; ++level)
{
unsigned int level_width = get_level_dimension(params->width, level);
unsigned int level_height = get_level_dimension(params->height, level);
unsigned int level_width = get_level_dimension(params->desc.width, level);
unsigned int level_height = get_level_dimension(params->desc.height, level);
resource_data[level].pSysMem = &params->data[buffer_offset];
resource_data[level].SysMemPitch = level_width * params->texel_size;
resource_data[level].SysMemPitch = level_width * params->desc.texel_size;
resource_data[level].SysMemSlicePitch = level_height * resource_data[level].SysMemPitch;
buffer_offset += resource_data[level].SysMemSlicePitch;
}
@ -428,11 +429,11 @@ static bool init_resource_2d(struct d3d11_shader_runner *runner, struct d3d11_re
ok(hr == S_OK, "Failed to create texture, hr %#lx.\n", hr);
resource->resource = (ID3D11Resource *)resource->texture;
if (params->type == RESOURCE_TYPE_UAV)
if (params->desc.type == RESOURCE_TYPE_UAV)
hr = ID3D11Device_CreateUnorderedAccessView(device, resource->resource, NULL, &resource->uav);
else if (params->type == RESOURCE_TYPE_RENDER_TARGET)
else if (params->desc.type == RESOURCE_TYPE_RENDER_TARGET)
hr = ID3D11Device_CreateRenderTargetView(device, resource->resource, NULL, &resource->rtv);
else if (params->type == RESOURCE_TYPE_DEPTH_STENCIL)
else if (params->desc.type == RESOURCE_TYPE_DEPTH_STENCIL)
hr = ID3D11Device_CreateDepthStencilView(device, resource->resource, NULL, &resource->dsv);
else
hr = ID3D11Device_CreateShaderResourceView(device, resource->resource, NULL, &resource->srv);
@ -452,10 +453,10 @@ static void init_resource_srv_buffer(struct d3d11_shader_runner *runner, struct
params->stride, params->data);
resource->resource = (ID3D11Resource *)resource->buffer;
srv_desc.Format = params->format;
srv_desc.Format = params->desc.format;
srv_desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
srv_desc.Buffer.FirstElement = 0;
srv_desc.Buffer.NumElements = params->data_size / params->texel_size;
srv_desc.Buffer.NumElements = params->data_size / params->desc.texel_size;
hr = ID3D11Device_CreateShaderResourceView(device, resource->resource, &srv_desc, &resource->srv);
ok(hr == S_OK, "Failed to create view, hr %#lx.\n", hr);
}
@ -472,10 +473,10 @@ static void init_resource_uav_buffer(struct d3d11_shader_runner *runner, struct
resource->resource = (ID3D11Resource *)resource->buffer;
resource->is_uav_counter = params->is_uav_counter;
uav_desc.Format = params->format;
uav_desc.Format = params->desc.format;
uav_desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
uav_desc.Buffer.FirstElement = 0;
uav_desc.Buffer.NumElements = params->data_size / params->texel_size;
uav_desc.Buffer.NumElements = params->data_size / params->desc.texel_size;
if (params->is_raw)
uav_desc.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_RAW;
else if (params->is_uav_counter)
@ -495,19 +496,19 @@ static struct resource *d3d11_runner_create_resource(struct shader_runner *r, co
resource = calloc(1, sizeof(*resource));
init_resource(&resource->r, params);
switch (params->type)
switch (params->desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
case RESOURCE_TYPE_DEPTH_STENCIL:
case RESOURCE_TYPE_TEXTURE:
if (params->dimension == RESOURCE_DIMENSION_BUFFER)
if (params->desc.dimension == RESOURCE_DIMENSION_BUFFER)
init_resource_srv_buffer(runner, resource, params);
else if (!init_resource_2d(runner, resource, params))
return NULL;
break;
case RESOURCE_TYPE_UAV:
if (params->dimension == RESOURCE_DIMENSION_BUFFER)
if (params->desc.dimension == RESOURCE_DIMENSION_BUFFER)
init_resource_uav_buffer(runner, resource, params);
else if (!init_resource_2d(runner, resource, params))
return NULL;
@ -590,14 +591,14 @@ static bool d3d11_runner_dispatch(struct shader_runner *r, unsigned int x, unsig
{
struct d3d11_resource *resource = d3d11_resource(runner->r.resources[i]);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_TEXTURE:
ID3D11DeviceContext_CSSetShaderResources(context, resource->r.slot, 1, &resource->srv);
ID3D11DeviceContext_CSSetShaderResources(context, resource->r.desc.slot, 1, &resource->srv);
break;
case RESOURCE_TYPE_UAV:
ID3D11DeviceContext_CSSetUnorderedAccessViews(context, resource->r.slot, 1, &resource->uav, NULL);
ID3D11DeviceContext_CSSetUnorderedAccessViews(context, resource->r.desc.slot, 1, &resource->uav, NULL);
break;
case RESOURCE_TYPE_RENDER_TARGET:
@ -631,7 +632,7 @@ static void d3d11_runner_clear(struct shader_runner *r, struct resource *res, co
ID3D11DeviceContext *context = runner->immediate_context;
struct d3d11_resource *resource = d3d11_resource(res);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
ID3D11DeviceContext_ClearRenderTargetView(context, resource->rtv, (const float *)clear_value);
@ -642,7 +643,7 @@ static void d3d11_runner_clear(struct shader_runner *r, struct resource *res, co
break;
default:
fatal_error("Clears are not implemented for resource type %u.\n", resource->r.type);
fatal_error("Clears are not implemented for resource type %u.\n", resource->r.desc.type);
}
}
@ -757,14 +758,14 @@ static bool d3d11_runner_draw(struct shader_runner *r,
for (i = 0; i < runner->r.resource_count; ++i)
{
struct d3d11_resource *resource = d3d11_resource(runner->r.resources[i]);
unsigned int stride = get_vb_stride(&runner->r, resource->r.slot);
unsigned int stride = get_vb_stride(&runner->r, resource->r.desc.slot);
unsigned int offset = 0;
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
rtvs[resource->r.slot] = resource->rtv;
rtv_count = max(rtv_count, resource->r.slot + 1);
rtvs[resource->r.desc.slot] = resource->rtv;
rtv_count = max(rtv_count, resource->r.desc.slot + 1);
break;
case RESOURCE_TYPE_DEPTH_STENCIL:
@ -778,16 +779,16 @@ static bool d3d11_runner_draw(struct shader_runner *r,
break;
case RESOURCE_TYPE_TEXTURE:
ID3D11DeviceContext_PSSetShaderResources(context, resource->r.slot, 1, &resource->srv);
ID3D11DeviceContext_PSSetShaderResources(context, resource->r.desc.slot, 1, &resource->srv);
break;
case RESOURCE_TYPE_UAV:
uavs[resource->r.slot] = resource->uav;
min_uav_slot = min(min_uav_slot, resource->r.slot);
uavs[resource->r.desc.slot] = resource->uav;
min_uav_slot = min(min_uav_slot, resource->r.desc.slot);
break;
case RESOURCE_TYPE_VERTEX_BUFFER:
ID3D11DeviceContext_IASetVertexBuffers(context, resource->r.slot, 1,
ID3D11DeviceContext_IASetVertexBuffers(context, resource->r.desc.slot, 1,
(ID3D11Buffer **)&resource->resource, &stride, &offset);
break;
}
@ -884,12 +885,12 @@ static struct resource_readback *d3d11_runner_get_resource_readback(struct shade
HRESULT hr;
src_resource = resource->resource;
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
case RESOURCE_TYPE_DEPTH_STENCIL:
case RESOURCE_TYPE_UAV:
if (resource->r.dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->r.desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
ID3D11Buffer_GetDesc(resource->buffer, &buffer_desc);
buffer_desc.Usage = D3D11_USAGE_STAGING;
@ -941,8 +942,8 @@ static struct resource_readback *d3d11_runner_get_resource_readback(struct shade
rb->rb.data = map_desc.pData;
rb->rb.row_pitch = map_desc.RowPitch;
rb->rb.width = resource->r.width;
rb->rb.height = resource->r.height;
rb->rb.width = resource->r.desc.width;
rb->rb.height = resource->r.desc.height;
rb->rb.depth = 1;
return &rb->rb;
}

View File

@ -114,48 +114,48 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
unsigned int buffer_offset = 0;
D3D12_RESOURCE_STATES state;
if (params->level_count > ARRAY_SIZE(resource_data))
fatal_error("Level count %u is too high.\n", params->level_count);
if (params->desc.level_count > ARRAY_SIZE(resource_data))
fatal_error("Level count %u is too high.\n", params->desc.level_count);
resource = calloc(1, sizeof(*resource));
init_resource(&resource->r, params);
for (unsigned int level = 0; level < params->level_count; ++level)
for (unsigned int level = 0; level < params->desc.level_count; ++level)
{
unsigned int level_width = get_level_dimension(params->width, level);
unsigned int level_height = get_level_dimension(params->height, level);
unsigned int level_width = get_level_dimension(params->desc.width, level);
unsigned int level_height = get_level_dimension(params->desc.height, level);
resource_data[level].pData = &params->data[buffer_offset];
resource_data[level].RowPitch = level_width * params->texel_size;
resource_data[level].RowPitch = level_width * params->desc.texel_size;
resource_data[level].SlicePitch = level_height * resource_data[level].RowPitch;
buffer_offset += resource_data[level].SlicePitch;
}
switch (params->type)
switch (params->desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
if (!runner->rtv_heap)
runner->rtv_heap = create_cpu_descriptor_heap(device,
D3D12_DESCRIPTOR_HEAP_TYPE_RTV, MAX_RESOURCE_DESCRIPTORS);
if (params->slot >= D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT)
fatal_error("RTV slot %u is too high.\n", params->slot);
if (params->sample_count > 1 && params->level_count > 1)
if (params->desc.slot >= D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT)
fatal_error("RTV slot %u is too high.\n", params->desc.slot);
if (params->desc.sample_count > 1 && params->desc.level_count > 1)
fatal_error("Multisampled texture has multiple levels.\n");
resource->resource = create_default_texture_(__LINE__, device, D3D12_RESOURCE_DIMENSION_TEXTURE2D,
params->width, params->height, 1, params->level_count, params->sample_count, params->format,
params->desc.width, params->desc.height, 1, params->desc.level_count, params->desc.sample_count, params->desc.format,
D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, D3D12_RESOURCE_STATE_RENDER_TARGET);
ID3D12Device_CreateRenderTargetView(device, resource->resource,
NULL, get_cpu_rtv_handle(test_context, runner->rtv_heap, resource->r.slot));
NULL, get_cpu_rtv_handle(test_context, runner->rtv_heap, resource->r.desc.slot));
break;
case RESOURCE_TYPE_DEPTH_STENCIL:
if (!runner->dsv_heap)
runner->dsv_heap = create_cpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_DSV, 1);
resource->resource = create_default_texture2d(device, params->width, params->height, 1, params->level_count,
params->format, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL, D3D12_RESOURCE_STATE_DEPTH_WRITE);
resource->resource = create_default_texture2d(device, params->desc.width, params->desc.height, 1, params->desc.level_count,
params->desc.format, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL, D3D12_RESOURCE_STATE_DEPTH_WRITE);
ID3D12Device_CreateDepthStencilView(device, resource->resource,
NULL, get_cpu_dsv_handle(test_context, runner->dsv_heap, 0));
break;
@ -165,7 +165,7 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
runner->heap = create_gpu_descriptor_heap(device,
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, MAX_RESOURCE_DESCRIPTORS);
if (params->dimension == RESOURCE_DIMENSION_BUFFER)
if (params->desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = { 0 };
@ -177,38 +177,38 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
reset_command_list(test_context->list, test_context->allocator);
srv_desc.Format = params->format;
srv_desc.Format = params->desc.format;
srv_desc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
srv_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
srv_desc.Buffer.NumElements = params->width * params->height;
srv_desc.Buffer.NumElements = params->desc.width * params->desc.height;
ID3D12Device_CreateShaderResourceView(device, resource->resource,
&srv_desc, get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot));
&srv_desc, get_cpu_descriptor_handle(test_context, runner->heap, resource->r.desc.slot));
}
else
{
if (params->sample_count > 1 && params->level_count > 1)
if (params->desc.sample_count > 1 && params->desc.level_count > 1)
fatal_error("Multisampled texture has multiple levels.\n");
resource->resource = create_default_texture_(__LINE__, device, D3D12_RESOURCE_DIMENSION_TEXTURE2D,
params->width, params->height, 1, params->level_count, params->sample_count, params->format,
params->desc.width, params->desc.height, 1, params->desc.level_count, params->desc.sample_count, params->desc.format,
/* Multisampled textures must have ALLOW_RENDER_TARGET set. */
(params->sample_count > 1) ? D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET : 0,
(params->desc.sample_count > 1) ? D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET : 0,
D3D12_RESOURCE_STATE_COPY_DEST);
if (params->data)
{
if (params->sample_count > 1)
if (params->desc.sample_count > 1)
fatal_error("Cannot upload data to a multisampled texture.\n");
upload_texture_data_with_states(resource->resource, resource_data,
params->level_count, test_context->queue, test_context->list,
params->desc.level_count, test_context->queue, test_context->list,
RESOURCE_STATE_DO_NOT_CHANGE,
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
reset_command_list(test_context->list, test_context->allocator);
}
ID3D12Device_CreateShaderResourceView(device, resource->resource,
NULL, get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot));
NULL, get_cpu_descriptor_handle(test_context, runner->heap, resource->r.desc.slot));
}
break;
@ -217,7 +217,7 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
runner->heap = create_gpu_descriptor_heap(device,
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, MAX_RESOURCE_DESCRIPTORS);
if (params->dimension == RESOURCE_DIMENSION_BUFFER)
if (params->desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
D3D12_UNORDERED_ACCESS_VIEW_DESC uav_desc = { 0 };
@ -228,30 +228,30 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
RESOURCE_STATE_DO_NOT_CHANGE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
reset_command_list(test_context->list, test_context->allocator);
uav_desc.Format = params->format;
uav_desc.Format = params->desc.format;
uav_desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
uav_desc.Buffer.NumElements = params->width * params->height;
uav_desc.Buffer.NumElements = params->desc.width * params->desc.height;
uav_desc.Buffer.StructureByteStride = params->stride;
uav_desc.Buffer.Flags = params->is_raw ? D3D12_BUFFER_UAV_FLAG_RAW : 0;
ID3D12Device_CreateUnorderedAccessView(device, resource->resource,
params->is_uav_counter ? resource->resource : NULL, &uav_desc,
get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES));
get_cpu_descriptor_handle(test_context, runner->heap, resource->r.desc.slot + MAX_RESOURCES));
}
else
{
state = params->data ? D3D12_RESOURCE_STATE_COPY_DEST : D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
resource->resource = create_default_texture2d(device, params->width, params->height, 1, params->level_count,
params->format, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, state);
resource->resource = create_default_texture2d(device, params->desc.width, params->desc.height, 1, params->desc.level_count,
params->desc.format, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, state);
if (params->data)
{
upload_texture_data_with_states(resource->resource, resource_data,
params->level_count, test_context->queue, test_context->list,
params->desc.level_count, test_context->queue, test_context->list,
RESOURCE_STATE_DO_NOT_CHANGE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
reset_command_list(test_context->list, test_context->allocator);
}
ID3D12Device_CreateUnorderedAccessView(device, resource->resource, NULL, NULL,
get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES));
get_cpu_descriptor_handle(test_context, runner->heap, resource->r.desc.slot + MAX_RESOURCES));
}
break;
@ -306,13 +306,13 @@ static ID3D12RootSignature *d3d12_runner_create_root_signature(struct d3d12_shad
struct d3d12_resource *resource = d3d12_resource(runner->r.resources[i]);
D3D12_DESCRIPTOR_RANGE *range;
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_TEXTURE:
case RESOURCE_TYPE_UAV:
range = &resource->descriptor_range;
if (base_resource && resource->r.type == base_resource->r.type && resource->r.slot == slot + 1)
if (base_resource && resource->r.desc.type == base_resource->r.desc.type && resource->r.desc.slot == slot + 1)
{
++base_resource->descriptor_range.NumDescriptors;
resource->descriptor_range.NumDescriptors = 0;
@ -327,17 +327,17 @@ static ID3D12RootSignature *d3d12_runner_create_root_signature(struct d3d12_shad
root_param->DescriptorTable.pDescriptorRanges = range;
root_param->ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
if (resource->r.type == RESOURCE_TYPE_UAV)
if (resource->r.desc.type == RESOURCE_TYPE_UAV)
range->RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV;
else
range->RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
range->NumDescriptors = 1;
range->BaseShaderRegister = resource->r.slot;
range->BaseShaderRegister = resource->r.desc.slot;
range->RegisterSpace = 0;
range->OffsetInDescriptorsFromTableStart = 0;
base_resource = resource;
slot = resource->r.slot;
slot = resource->r.desc.slot;
break;
case RESOURCE_TYPE_RENDER_TARGET:
@ -424,18 +424,18 @@ static bool d3d12_runner_dispatch(struct shader_runner *r, unsigned int x, unsig
{
struct d3d12_resource *resource = d3d12_resource(runner->r.resources[i]);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_TEXTURE:
if (resource->descriptor_range.NumDescriptors)
ID3D12GraphicsCommandList_SetComputeRootDescriptorTable(command_list, resource->root_index,
get_gpu_descriptor_handle(test_context, runner->heap, resource->r.slot));
get_gpu_descriptor_handle(test_context, runner->heap, resource->r.desc.slot));
break;
case RESOURCE_TYPE_UAV:
if (resource->descriptor_range.NumDescriptors)
ID3D12GraphicsCommandList_SetComputeRootDescriptorTable(command_list, resource->root_index,
get_gpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES));
get_gpu_descriptor_handle(test_context, runner->heap, resource->r.desc.slot + MAX_RESOURCES));
break;
case RESOURCE_TYPE_RENDER_TARGET:
@ -472,10 +472,10 @@ static void d3d12_runner_clear(struct shader_runner *r, struct resource *resourc
D3D12_CPU_DESCRIPTOR_HANDLE view;
HRESULT hr;
switch (resource->type)
switch (resource->desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
view = get_cpu_rtv_handle(test_context, runner->rtv_heap, resource->slot);
view = get_cpu_rtv_handle(test_context, runner->rtv_heap, resource->desc.slot);
ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, view, (const float *)clear_value, 0, NULL);
break;
@ -486,7 +486,7 @@ static void d3d12_runner_clear(struct shader_runner *r, struct resource *resourc
break;
default:
fatal_error("Clears are not implemented for resource type %u.\n", resource->type);
fatal_error("Clears are not implemented for resource type %u.\n", resource->desc.type);
}
hr = ID3D12GraphicsCommandList_Close(command_list);
@ -588,18 +588,18 @@ static bool d3d12_runner_draw(struct shader_runner *r,
{
struct d3d12_resource *resource = d3d12_resource(runner->r.resources[i]);
if (resource->r.type == RESOURCE_TYPE_RENDER_TARGET)
if (resource->r.desc.type == RESOURCE_TYPE_RENDER_TARGET)
{
pso_desc.RTVFormats[resource->r.slot] = resource->r.format;
pso_desc.NumRenderTargets = max(pso_desc.NumRenderTargets, resource->r.slot + 1);
pso_desc.BlendState.RenderTarget[resource->r.slot].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL;
if (resource->r.sample_count)
sample_count = resource->r.sample_count;
pso_desc.RTVFormats[resource->r.desc.slot] = resource->r.desc.format;
pso_desc.NumRenderTargets = max(pso_desc.NumRenderTargets, resource->r.desc.slot + 1);
pso_desc.BlendState.RenderTarget[resource->r.desc.slot].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL;
if (resource->r.desc.sample_count)
sample_count = resource->r.desc.sample_count;
}
else if (resource->r.type == RESOURCE_TYPE_DEPTH_STENCIL)
else if (resource->r.desc.type == RESOURCE_TYPE_DEPTH_STENCIL)
{
assert(!resource->r.slot);
pso_desc.DSVFormat = resource->r.format;
assert(!resource->r.desc.slot);
pso_desc.DSVFormat = resource->r.desc.format;
pso_desc.DepthStencilState.DepthEnable = true;
pso_desc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
pso_desc.DepthStencilState.DepthFunc = runner->r.depth_func;
@ -675,11 +675,11 @@ static bool d3d12_runner_draw(struct shader_runner *r,
struct d3d12_resource *resource = d3d12_resource(runner->r.resources[i]);
D3D12_VERTEX_BUFFER_VIEW vbv;
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
rtvs[resource->r.slot] = get_cpu_rtv_handle(test_context, runner->rtv_heap, resource->r.slot);
rtv_count = max(rtv_count, resource->r.slot + 1);
rtvs[resource->r.desc.slot] = get_cpu_rtv_handle(test_context, runner->rtv_heap, resource->r.desc.slot);
rtv_count = max(rtv_count, resource->r.desc.slot + 1);
break;
case RESOURCE_TYPE_DEPTH_STENCIL:
@ -689,21 +689,21 @@ static bool d3d12_runner_draw(struct shader_runner *r,
case RESOURCE_TYPE_TEXTURE:
if (resource->descriptor_range.NumDescriptors)
ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, resource->root_index,
get_gpu_descriptor_handle(test_context, runner->heap, resource->r.slot));
get_gpu_descriptor_handle(test_context, runner->heap, resource->r.desc.slot));
break;
case RESOURCE_TYPE_UAV:
if (resource->descriptor_range.NumDescriptors)
ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, resource->root_index,
get_gpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES));
get_gpu_descriptor_handle(test_context, runner->heap, resource->r.desc.slot + MAX_RESOURCES));
break;
case RESOURCE_TYPE_VERTEX_BUFFER:
vbv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(resource->resource);
vbv.StrideInBytes = get_vb_stride(&runner->r, resource->r.slot);
vbv.SizeInBytes = resource->r.width;
vbv.StrideInBytes = get_vb_stride(&runner->r, resource->r.desc.slot);
vbv.SizeInBytes = resource->r.desc.width;
ID3D12GraphicsCommandList_IASetVertexBuffers(command_list, resource->r.slot, 1, &vbv);
ID3D12GraphicsCommandList_IASetVertexBuffers(command_list, resource->r.desc.slot, 1, &vbv);
break;
}
}
@ -734,9 +734,9 @@ static struct resource_readback *d3d12_runner_get_resource_readback(struct shade
struct d3d12_resource *resource = d3d12_resource(res);
D3D12_RESOURCE_STATES state;
if (resource->r.type == RESOURCE_TYPE_RENDER_TARGET)
if (resource->r.desc.type == RESOURCE_TYPE_RENDER_TARGET)
state = D3D12_RESOURCE_STATE_RENDER_TARGET;
else if (resource->r.type == RESOURCE_TYPE_DEPTH_STENCIL)
else if (resource->r.desc.type == RESOURCE_TYPE_DEPTH_STENCIL)
state = D3D12_RESOURCE_STATE_DEPTH_WRITE;
else
state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;

View File

@ -201,7 +201,7 @@ static struct resource *d3d9_runner_create_resource(struct shader_runner *r, con
resource = calloc(1, sizeof(*resource));
init_resource(&resource->r, params);
switch (params->format)
switch (params->desc.format)
{
case DXGI_FORMAT_R32G32B32A32_FLOAT:
format = D3DFMT_A32B32G32R32F;
@ -216,10 +216,10 @@ static struct resource *d3d9_runner_create_resource(struct shader_runner *r, con
break;
}
switch (params->type)
switch (params->desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
hr = IDirect3DDevice9_CreateRenderTarget(device, params->width, params->height,
hr = IDirect3DDevice9_CreateRenderTarget(device, params->desc.width, params->desc.height,
format, D3DMULTISAMPLE_NONE, 0, FALSE, &resource->surface, NULL);
ok(hr == D3D_OK, "Failed to create render target, hr %#lx.\n", hr);
break;
@ -230,7 +230,7 @@ static struct resource *d3d9_runner_create_resource(struct shader_runner *r, con
case RESOURCE_TYPE_TEXTURE:
{
if (params->dimension == RESOURCE_DIMENSION_BUFFER)
if (params->desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
fatal_error("Buffer resources are not supported.\n");
break;
@ -238,15 +238,15 @@ static struct resource *d3d9_runner_create_resource(struct shader_runner *r, con
unsigned int src_buffer_offset = 0;
hr = IDirect3DDevice9_CreateTexture(device, params->width, params->height,
params->level_count, 0, format, D3DPOOL_MANAGED, &resource->texture, NULL);
hr = IDirect3DDevice9_CreateTexture(device, params->desc.width, params->desc.height,
params->desc.level_count, 0, format, D3DPOOL_MANAGED, &resource->texture, NULL);
ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
for (unsigned int level = 0; level < params->level_count; ++level)
for (unsigned int level = 0; level < params->desc.level_count; ++level)
{
unsigned int level_width = get_level_dimension(params->width, level);
unsigned int level_height = get_level_dimension(params->height, level);
unsigned int src_row_pitch = level_width * params->texel_size;
unsigned int level_width = get_level_dimension(params->desc.width, level);
unsigned int level_height = get_level_dimension(params->desc.height, level);
unsigned int src_row_pitch = level_width * params->desc.texel_size;
unsigned int src_slice_pitch = level_height * src_row_pitch;
hr = IDirect3DTexture9_LockRect(resource->texture, level, &map_desc, NULL, 0);
@ -387,10 +387,10 @@ static bool d3d9_runner_draw(struct shader_runner *r,
struct d3d9_resource *resource = d3d9_resource(runner->r.resources[i]);
unsigned int stride = 0;
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
hr = IDirect3DDevice9_SetRenderTarget(device, resource->r.slot, resource->surface);
hr = IDirect3DDevice9_SetRenderTarget(device, resource->r.desc.slot, resource->surface);
ok(hr == D3D_OK, "Failed to set render target, hr %#lx.\n", hr);
break;
@ -398,9 +398,9 @@ static bool d3d9_runner_draw(struct shader_runner *r,
vkd3d_unreachable();
case RESOURCE_TYPE_TEXTURE:
assert(resource->r.dimension != RESOURCE_DIMENSION_BUFFER);
assert(resource->r.desc.dimension != RESOURCE_DIMENSION_BUFFER);
hr = IDirect3DDevice9_SetTexture(device, resource->r.slot, (IDirect3DBaseTexture9 *)resource->texture);
hr = IDirect3DDevice9_SetTexture(device, resource->r.desc.slot, (IDirect3DBaseTexture9 *)resource->texture);
ok(hr == D3D_OK, "Failed to set texture, hr %#lx.\n", hr);
break;
@ -410,14 +410,14 @@ static bool d3d9_runner_draw(struct shader_runner *r,
case RESOURCE_TYPE_VERTEX_BUFFER:
for (j = 0; j < runner->r.input_element_count; ++j)
{
if (runner->r.input_elements[j].slot == resource->r.slot)
if (runner->r.input_elements[j].slot == resource->r.desc.slot)
{
decl_elements[j].Offset = stride;
stride += runner->r.input_elements[j].texel_size;
}
}
hr = IDirect3DDevice9_SetStreamSource(device, resource->r.slot, resource->vb, 0, stride);
hr = IDirect3DDevice9_SetStreamSource(device, resource->r.desc.slot, resource->vb, 0, stride);
ok(hr == D3D_OK, "Failed to set vertex buffer, hr %#lx.\n", hr);
break;
}
@ -507,7 +507,7 @@ static struct resource_readback *d3d9_runner_get_resource_readback(struct shader
D3DSURFACE_DESC desc;
HRESULT hr;
assert(resource->r.type == RESOURCE_TYPE_RENDER_TARGET);
assert(resource->r.desc.type == RESOURCE_TYPE_RENDER_TARGET);
hr = IDirect3DSurface9_GetDesc(resource->surface, &desc);
ok(hr == D3D_OK, "Failed to get surface desc, hr %#lx.\n", hr);

View File

@ -357,36 +357,36 @@ static bool init_resource_2d(struct gl_resource *resource, const struct resource
{
unsigned int offset, w, h, i;
resource->format = get_format_info(params->format, params->is_shadow);
resource->format = get_format_info(params->desc.format, params->is_shadow);
if (params->sample_count > 1)
if (params->desc.sample_count > 1)
{
GLint max_sample_count;
glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, resource->format->internal_format, GL_SAMPLES, 1, &max_sample_count);
if (max_sample_count < params->sample_count)
if (max_sample_count < params->desc.sample_count)
{
trace("Format #%x with sample count %u is not supported; skipping.\n", params->format, params->sample_count);
trace("Format #%x with sample count %u is not supported; skipping.\n", params->desc.format, params->desc.sample_count);
return false;
}
}
glGenTextures(1, &resource->id);
glBindTexture(GL_TEXTURE_2D, resource->id);
glTexStorage2D(GL_TEXTURE_2D, params->level_count,
resource->format->internal_format, params->width, params->height);
glTexStorage2D(GL_TEXTURE_2D, params->desc.level_count,
resource->format->internal_format, params->desc.width, params->desc.height);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
if (!params->data)
return true;
for (i = 0, offset = 0; i < params->level_count; ++i)
for (i = 0, offset = 0; i < params->desc.level_count; ++i)
{
w = get_level_dimension(params->width, i);
h = get_level_dimension(params->height, i);
w = get_level_dimension(params->desc.width, i);
h = get_level_dimension(params->desc.height, i);
glTexSubImage2D(GL_TEXTURE_2D, i, 0, 0, w, h, resource->format->format,
resource->format->type, params->data + offset);
offset += w * h * params->texel_size;
offset += w * h * params->desc.texel_size;
}
return true;
@ -394,7 +394,7 @@ static bool init_resource_2d(struct gl_resource *resource, const struct resource
static void init_resource_buffer(struct gl_resource *resource, const struct resource_params *params)
{
resource->format = get_format_info(params->format, false);
resource->format = get_format_info(params->desc.format, false);
glGenBuffers(1, &resource->id);
glBindBuffer(GL_TEXTURE_BUFFER, resource->id);
@ -412,13 +412,13 @@ static struct resource *gl_runner_create_resource(struct shader_runner *r, const
resource = calloc(1, sizeof(*resource));
init_resource(&resource->r, params);
switch (params->type)
switch (params->desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
case RESOURCE_TYPE_DEPTH_STENCIL:
case RESOURCE_TYPE_TEXTURE:
case RESOURCE_TYPE_UAV:
if (params->dimension == RESOURCE_DIMENSION_BUFFER)
if (params->desc.dimension == RESOURCE_DIMENSION_BUFFER)
init_resource_buffer(resource, params);
else if (!init_resource_2d(resource, params))
return NULL;
@ -438,13 +438,13 @@ static void gl_runner_destroy_resource(struct shader_runner *r, struct resource
{
struct gl_resource *resource = gl_resource(res);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
case RESOURCE_TYPE_DEPTH_STENCIL:
case RESOURCE_TYPE_TEXTURE:
case RESOURCE_TYPE_UAV:
if (res->dimension == RESOURCE_DIMENSION_BUFFER)
if (res->desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
glDeleteTextures(1, &resource->tbo_id);
glDeleteBuffers(1, &resource->id);
@ -580,20 +580,20 @@ static bool compile_shader(struct gl_runner *runner, ID3DBlob *blob, struct vkd3
{
const struct gl_resource *resource = gl_resource(runner->r.resources[i]);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_UAV:
binding = &bindings[interface_info.binding_count++];
binding->type = VKD3D_SHADER_DESCRIPTOR_TYPE_UAV;
binding->register_space = 0;
binding->register_index = resource->r.slot;
binding->register_index = resource->r.desc.slot;
binding->shader_visibility = VKD3D_SHADER_VISIBILITY_ALL;
if (resource->r.dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->r.desc.dimension == RESOURCE_DIMENSION_BUFFER)
binding->flags = VKD3D_SHADER_BINDING_FLAG_BUFFER;
else
binding->flags = VKD3D_SHADER_BINDING_FLAG_IMAGE;
binding->binding.set = 0;
binding->binding.binding = resource->r.slot;
binding->binding.binding = resource->r.desc.slot;
binding->binding.count = 1;
break;
@ -725,7 +725,7 @@ static bool gl_runner_dispatch(struct shader_runner *r, unsigned int x, unsigned
{
struct gl_resource *resource = gl_resource(runner->r.resources[i]);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
case RESOURCE_TYPE_DEPTH_STENCIL:
@ -734,8 +734,8 @@ static bool gl_runner_dispatch(struct shader_runner *r, unsigned int x, unsigned
break;
case RESOURCE_TYPE_UAV:
if (resource->r.dimension != RESOURCE_DIMENSION_BUFFER)
glBindImageTexture(resource->r.slot, resource->id, 0, GL_TRUE,
if (resource->r.desc.dimension != RESOURCE_DIMENSION_BUFFER)
glBindImageTexture(resource->r.desc.slot, resource->id, 0, GL_TRUE,
0, GL_READ_WRITE, resource->format->internal_format);
break;
}
@ -957,7 +957,7 @@ static void gl_runner_clear(struct shader_runner *r, struct resource *res, const
glGenFramebuffers(1, &runner->fbo_id);
glBindFramebuffer(GL_FRAMEBUFFER, runner->fbo_id);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, resource->id, 0);
@ -974,10 +974,10 @@ static void gl_runner_clear(struct shader_runner *r, struct resource *res, const
break;
default:
fatal_error("Clears are not implemented for resource type %u.\n", resource->r.type);
fatal_error("Clears are not implemented for resource type %u.\n", resource->r.desc.type);
}
glScissor(0, 0, res->width, res->height);
glScissor(0, 0, res->desc.width, res->desc.height);
glClear(clear_mask);
}
@ -1053,7 +1053,7 @@ static bool gl_runner_draw(struct shader_runner *r,
if (!(resource = shader_runner_get_resource(r, RESOURCE_TYPE_TEXTURE, s->resource_index)))
fatal_error("Resource not found.\n");
if (resource->dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
glActiveTexture(GL_TEXTURE0 + s->binding.binding);
glBindTexture(GL_TEXTURE_BUFFER, gl_resource(resource)->tbo_id);
@ -1078,15 +1078,15 @@ static bool gl_runner_draw(struct shader_runner *r,
{
struct gl_resource *resource = gl_resource(runner->r.resources[i]);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + resource->r.slot, resource->id, 0);
if (resource->r.slot >= ARRAY_SIZE(draw_buffers))
fatal_error("Unsupported render target index %u.\n", resource->r.slot);
draw_buffers[resource->r.slot] = GL_COLOR_ATTACHMENT0 + resource->r.slot;
if (resource->r.slot >= rt_count)
rt_count = resource->r.slot + 1;
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + resource->r.desc.slot, resource->id, 0);
if (resource->r.desc.slot >= ARRAY_SIZE(draw_buffers))
fatal_error("Unsupported render target index %u.\n", resource->r.desc.slot);
draw_buffers[resource->r.desc.slot] = GL_COLOR_ATTACHMENT0 + resource->r.desc.slot;
if (resource->r.desc.slot >= rt_count)
rt_count = resource->r.desc.slot + 1;
break;
case RESOURCE_TYPE_DEPTH_STENCIL:
@ -1100,28 +1100,28 @@ static bool gl_runner_draw(struct shader_runner *r,
break;
case RESOURCE_TYPE_UAV:
if (resource->r.dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->r.desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
glBindImageTexture(resource->r.slot, resource->tbo_id, 0, GL_TRUE,
glBindImageTexture(resource->r.desc.slot, resource->tbo_id, 0, GL_TRUE,
0, GL_READ_WRITE, resource->format->internal_format);
}
else
{
glBindImageTexture(resource->r.slot, resource->id, 0, GL_TRUE,
glBindImageTexture(resource->r.desc.slot, resource->id, 0, GL_TRUE,
0, GL_READ_WRITE, resource->format->internal_format);
}
break;
case RESOURCE_TYPE_VERTEX_BUFFER:
assert(resource->r.slot < ARRAY_SIZE(vbo_info));
vbo_info[resource->r.slot].id = resource->id;
assert(resource->r.desc.slot < ARRAY_SIZE(vbo_info));
vbo_info[resource->r.desc.slot].id = resource->id;
for (j = 0; j < runner->r.input_element_count; ++j)
{
if (runner->r.input_elements[j].slot != resource->r.slot)
if (runner->r.input_elements[j].slot != resource->r.desc.slot)
continue;
assert(j < ARRAY_SIZE(attribute_offsets));
attribute_offsets[j] = (uint8_t *)(uintptr_t)vbo_info[resource->r.slot].stride;
vbo_info[resource->r.slot].stride += runner->r.input_elements[j].texel_size;
attribute_offsets[j] = (uint8_t *)(uintptr_t)vbo_info[resource->r.desc.slot].stride;
vbo_info[resource->r.desc.slot].stride += runner->r.input_elements[j].texel_size;
}
break;
}
@ -1193,20 +1193,20 @@ static struct resource_readback *gl_runner_get_resource_readback(struct shader_r
struct gl_resource *resource = gl_resource(res);
struct resource_readback *rb;
if (resource->r.type != RESOURCE_TYPE_RENDER_TARGET && resource->r.type != RESOURCE_TYPE_DEPTH_STENCIL
&& resource->r.type != RESOURCE_TYPE_UAV)
fatal_error("Unhandled resource type %#x.\n", resource->r.type);
if (resource->r.desc.type != RESOURCE_TYPE_RENDER_TARGET && resource->r.desc.type != RESOURCE_TYPE_DEPTH_STENCIL
&& resource->r.desc.type != RESOURCE_TYPE_UAV)
fatal_error("Unhandled resource type %#x.\n", resource->r.desc.type);
rb = malloc(sizeof(*rb));
rb->width = resource->r.width;
rb->height = resource->r.height;
rb->width = resource->r.desc.width;
rb->height = resource->r.desc.height;
rb->depth = 1;
rb->row_pitch = rb->width * resource->r.texel_size;
rb->row_pitch = rb->width * resource->r.desc.texel_size;
rb->data = malloc(rb->row_pitch * rb->height);
if (resource->r.dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->r.desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
glBindBuffer(GL_TEXTURE_BUFFER, resource->id);
glGetBufferSubData(GL_TEXTURE_BUFFER, 0, rb->row_pitch * rb->height, rb->data);

View File

@ -268,20 +268,20 @@ static void resource_init_2d(struct vulkan_shader_runner *runner, struct vulkan_
{
VkImageUsageFlagBits usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
VkImageLayout layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
VkFormat format = vkd3d_get_vk_format(params->format);
VkFormat format = vkd3d_get_vk_format(params->desc.format);
VkDevice device = runner->device;
unsigned int buffer_offset = 0;
VkDeviceMemory staging_memory;
VkBuffer staging_buffer;
void *data;
if (params->type == RESOURCE_TYPE_UAV)
if (params->desc.type == RESOURCE_TYPE_UAV)
{
layout = VK_IMAGE_LAYOUT_GENERAL;
usage |= VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
}
resource->image = create_2d_image(runner, params->width, params->height, params->level_count,
resource->image = create_2d_image(runner, params->desc.width, params->desc.height, params->desc.level_count,
usage, format, &resource->memory);
resource->image_view = create_2d_image_view(runner, resource->image, format, VK_IMAGE_ASPECT_COLOR_BIT);
@ -305,10 +305,10 @@ static void resource_init_2d(struct vulkan_shader_runner *runner, struct vulkan_
transition_image_layout(runner, resource->image, VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
for (unsigned int level = 0; level < params->level_count; ++level)
for (unsigned int level = 0; level < params->desc.level_count; ++level)
{
unsigned int level_width = get_level_dimension(params->width, level);
unsigned int level_height = get_level_dimension(params->height, level);
unsigned int level_width = get_level_dimension(params->desc.width, level);
unsigned int level_height = get_level_dimension(params->desc.height, level);
VkBufferImageCopy region = {0};
region.bufferOffset = buffer_offset;
@ -321,7 +321,7 @@ static void resource_init_2d(struct vulkan_shader_runner *runner, struct vulkan_
VK_CALL(vkCmdCopyBufferToImage(runner->cmd_buffer, staging_buffer, resource->image,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &region));
buffer_offset += level_width * level_height * params->texel_size;
buffer_offset += level_width * level_height * params->desc.texel_size;
}
transition_image_layout(runner, resource->image, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, layout);
@ -335,12 +335,12 @@ static void resource_init_2d(struct vulkan_shader_runner *runner, struct vulkan_
static void resource_init_buffer(struct vulkan_shader_runner *runner, struct vulkan_resource *resource,
const struct resource_params *params)
{
VkFormat format = vkd3d_get_vk_format(params->format);
VkFormat format = vkd3d_get_vk_format(params->desc.format);
VkDevice device = runner->device;
VkBufferUsageFlagBits usage;
void *data;
if (params->type == RESOURCE_TYPE_UAV)
if (params->desc.type == RESOURCE_TYPE_UAV)
usage = VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
else
usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
@ -369,12 +369,12 @@ static struct resource *vulkan_runner_create_resource(struct shader_runner *r, c
resource = calloc(1, sizeof(*resource));
init_resource(&resource->r, params);
switch (params->type)
switch (params->desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
format = vkd3d_get_vk_format(params->format);
format = vkd3d_get_vk_format(params->desc.format);
resource->image = create_2d_image(runner, params->width, params->height, params->level_count,
resource->image = create_2d_image(runner, params->desc.width, params->desc.height, params->desc.level_count,
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, format, &resource->memory);
resource->image_view = create_2d_image_view(runner, resource->image, format, VK_IMAGE_ASPECT_COLOR_BIT);
@ -385,9 +385,9 @@ static struct resource *vulkan_runner_create_resource(struct shader_runner *r, c
break;
case RESOURCE_TYPE_DEPTH_STENCIL:
format = vkd3d_get_vk_format(params->format);
format = vkd3d_get_vk_format(params->desc.format);
resource->image = create_2d_image(runner, params->width, params->height, params->level_count,
resource->image = create_2d_image(runner, params->desc.width, params->desc.height, params->desc.level_count,
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, format,
&resource->memory);
resource->image_view = create_2d_image_view(runner, resource->image, format, VK_IMAGE_ASPECT_DEPTH_BIT);
@ -400,7 +400,7 @@ static struct resource *vulkan_runner_create_resource(struct shader_runner *r, c
case RESOURCE_TYPE_TEXTURE:
case RESOURCE_TYPE_UAV:
if (params->dimension == RESOURCE_DIMENSION_BUFFER)
if (params->desc.dimension == RESOURCE_DIMENSION_BUFFER)
resource_init_buffer(runner, resource, params);
else
resource_init_2d(runner, resource, params);
@ -553,7 +553,7 @@ static bool compile_shader(struct vulkan_shader_runner *runner, const char *sour
{
const struct vulkan_resource *resource = vulkan_resource(runner->r.resources[i]);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
case RESOURCE_TYPE_DEPTH_STENCIL:
@ -563,14 +563,14 @@ static bool compile_shader(struct vulkan_shader_runner *runner, const char *sour
case RESOURCE_TYPE_TEXTURE:
case RESOURCE_TYPE_UAV:
binding = &bindings[interface_info.binding_count++];
if (resource->r.type == RESOURCE_TYPE_UAV)
if (resource->r.desc.type == RESOURCE_TYPE_UAV)
binding->type = VKD3D_SHADER_DESCRIPTOR_TYPE_UAV;
else
binding->type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV;
binding->register_space = 0;
binding->register_index = resource->r.slot;
binding->register_index = resource->r.desc.slot;
binding->shader_visibility = VKD3D_SHADER_VISIBILITY_ALL;
if (resource->r.dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->r.desc.dimension == RESOURCE_DIMENSION_BUFFER)
binding->flags = VKD3D_SHADER_BINDING_FLAG_BUFFER;
else
binding->flags = VKD3D_SHADER_BINDING_FLAG_IMAGE;
@ -792,7 +792,7 @@ static VkPipeline create_graphics_pipeline(struct vulkan_shader_runner *runner,
{
const struct vulkan_resource *resource = vulkan_resource(runner->r.resources[i]);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_TEXTURE:
case RESOURCE_TYPE_UAV:
@ -822,13 +822,13 @@ static VkPipeline create_graphics_pipeline(struct vulkan_shader_runner *runner,
{
VkVertexInputBindingDescription *binding = &input_bindings[input_desc.vertexBindingDescriptionCount++];
binding->binding = resource->r.slot;
binding->binding = resource->r.desc.slot;
binding->stride = 0;
binding->inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
for (j = 0; j < runner->r.input_element_count; ++j)
{
if (runner->r.input_elements[j].slot == resource->r.slot)
if (runner->r.input_elements[j].slot == resource->r.desc.slot)
{
input_attributes[j].offset = binding->stride;
binding->stride += runner->r.input_elements[j].texel_size;
@ -943,7 +943,7 @@ static VkDescriptorSetLayout create_descriptor_set_layout(struct vulkan_shader_r
{
struct vulkan_resource *resource = vulkan_resource(runner->r.resources[i]);
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
case RESOURCE_TYPE_DEPTH_STENCIL:
@ -957,16 +957,16 @@ static VkDescriptorSetLayout create_descriptor_set_layout(struct vulkan_shader_r
resource->binding = binding_index++;
binding->binding = resource->binding;
if (resource->r.type == RESOURCE_TYPE_UAV)
if (resource->r.desc.type == RESOURCE_TYPE_UAV)
{
if (resource->r.dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->r.desc.dimension == RESOURCE_DIMENSION_BUFFER)
binding->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
else
binding->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
}
else
{
if (resource->r.dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->r.desc.dimension == RESOURCE_DIMENSION_BUFFER)
binding->descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
else
binding->descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
@ -1032,11 +1032,11 @@ static void bind_resources(struct vulkan_shader_runner *runner, VkPipelineBindPo
static const VkDeviceSize zero_offset;
VkDescriptorImageInfo image_info;
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_TEXTURE:
case RESOURCE_TYPE_UAV:
if (resource->r.dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->r.desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
write.dstSet = descriptor_set;
write.dstBinding = resource->binding;
@ -1045,7 +1045,7 @@ static void bind_resources(struct vulkan_shader_runner *runner, VkPipelineBindPo
write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
write.pTexelBufferView = &resource->buffer_view;
if (resource->r.type == RESOURCE_TYPE_UAV)
if (resource->r.desc.type == RESOURCE_TYPE_UAV)
write.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
VK_CALL(vkUpdateDescriptorSets(runner->device, 1, &write, 0, NULL));
@ -1062,7 +1062,7 @@ static void bind_resources(struct vulkan_shader_runner *runner, VkPipelineBindPo
write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
write.pImageInfo = &image_info;
if (resource->r.type == RESOURCE_TYPE_UAV)
if (resource->r.desc.type == RESOURCE_TYPE_UAV)
{
image_info.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
write.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
@ -1074,7 +1074,7 @@ static void bind_resources(struct vulkan_shader_runner *runner, VkPipelineBindPo
case RESOURCE_TYPE_VERTEX_BUFFER:
if (bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS)
VK_CALL(vkCmdBindVertexBuffers(cmd_buffer, resource->r.slot, 1, &resource->buffer, &zero_offset));
VK_CALL(vkCmdBindVertexBuffers(cmd_buffer, resource->r.desc.slot, 1, &resource->buffer, &zero_offset));
break;
case RESOURCE_TYPE_RENDER_TARGET:
@ -1111,13 +1111,13 @@ static void create_render_pass_and_framebuffer(struct vulkan_shader_runner *runn
VkAttachmentDescription *attachment_desc = &attachment_descs[view_count];
VkAttachmentReference *color_ref = &color_refs[color_ref_count];
if (resource->r.type != RESOURCE_TYPE_RENDER_TARGET && resource->r.type != RESOURCE_TYPE_DEPTH_STENCIL)
if (resource->r.desc.type != RESOURCE_TYPE_RENDER_TARGET && resource->r.desc.type != RESOURCE_TYPE_DEPTH_STENCIL)
continue;
is_ds = resource->r.type == RESOURCE_TYPE_DEPTH_STENCIL;
is_ds = resource->r.desc.type == RESOURCE_TYPE_DEPTH_STENCIL;
layout = is_ds ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
attachment_desc->format = vkd3d_get_vk_format(resource->r.format);
attachment_desc->format = vkd3d_get_vk_format(resource->r.desc.format);
attachment_desc->samples = VK_SAMPLE_COUNT_1_BIT;
attachment_desc->loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
attachment_desc->storeOp = VK_ATTACHMENT_STORE_OP_STORE;
@ -1211,7 +1211,7 @@ static void vulkan_runner_clear(struct shader_runner *r, struct resource *res, c
struct vulkan_shader_runner *runner = vulkan_shader_runner(r);
struct vulkan_resource *resource = vulkan_resource(res);
size_t width = resource->r.width, height = resource->r.height;
size_t width = resource->r.desc.width, height = resource->r.desc.height;
VkSubpassDescription sub_pass_desc = {0};
VkAttachmentDescription attachment_desc;
VkRenderPassCreateInfo pass_desc = {0};
@ -1224,7 +1224,7 @@ static void vulkan_runner_clear(struct shader_runner *r, struct resource *res, c
VkFramebuffer fb;
attachment_desc.flags = 0;
attachment_desc.format = vkd3d_get_vk_format(resource->r.format);
attachment_desc.format = vkd3d_get_vk_format(resource->r.desc.format);
attachment_desc.samples = VK_SAMPLE_COUNT_1_BIT;
attachment_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachment_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
@ -1234,7 +1234,7 @@ static void vulkan_runner_clear(struct shader_runner *r, struct resource *res, c
sub_pass_desc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
switch (resource->r.type)
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
attachment_desc.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
@ -1251,7 +1251,7 @@ static void vulkan_runner_clear(struct shader_runner *r, struct resource *res, c
break;
default:
fatal_error("Clears are not implemented for resource type %u.\n", resource->r.type);
fatal_error("Clears are not implemented for resource type %u.\n", resource->r.desc.type);
}
attachment_desc.finalLayout = attachment_desc.initialLayout;
@ -1374,16 +1374,16 @@ static struct resource_readback *vulkan_runner_get_resource_readback(struct shad
VkBufferImageCopy region = {0};
VkImageLayout layout;
rb->rb.width = resource->r.width;
rb->rb.height = resource->r.height;
rb->rb.width = resource->r.desc.width;
rb->rb.height = resource->r.desc.height;
rb->rb.depth = 1;
rb->rb.row_pitch = rb->rb.width * resource->r.texel_size;
rb->rb.row_pitch = rb->rb.width * resource->r.desc.texel_size;
rb->buffer = create_buffer(runner, rb->rb.row_pitch * rb->rb.height,
VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &rb->memory);
if (resource->r.type == RESOURCE_TYPE_UAV && resource->r.dimension == RESOURCE_DIMENSION_BUFFER)
if (resource->r.desc.type == RESOURCE_TYPE_UAV && resource->r.desc.dimension == RESOURCE_DIMENSION_BUFFER)
{
void *data;
@ -1394,12 +1394,12 @@ static struct resource_readback *vulkan_runner_get_resource_readback(struct shad
}
else
{
aspect_mask = (resource->r.type == RESOURCE_TYPE_DEPTH_STENCIL)
aspect_mask = (resource->r.desc.type == RESOURCE_TYPE_DEPTH_STENCIL)
? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
if (resource->r.type == RESOURCE_TYPE_RENDER_TARGET)
if (resource->r.desc.type == RESOURCE_TYPE_RENDER_TARGET)
layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
else if (resource->r.type == RESOURCE_TYPE_DEPTH_STENCIL)
else if (resource->r.desc.type == RESOURCE_TYPE_DEPTH_STENCIL)
layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
else
layout = VK_IMAGE_LAYOUT_GENERAL;
@ -1410,8 +1410,8 @@ static struct resource_readback *vulkan_runner_get_resource_readback(struct shad
region.imageSubresource.aspectMask = aspect_mask;
region.imageSubresource.layerCount = 1;
region.imageExtent.width = resource->r.width;
region.imageExtent.height = resource->r.height;
region.imageExtent.width = resource->r.desc.width;
region.imageExtent.height = resource->r.desc.height;
region.imageExtent.depth = 1;
VK_CALL(vkCmdCopyImageToBuffer(runner->cmd_buffer, resource->image,