vkd3d-shader: Use flag for vkd3d_shader_meta bools.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
This commit is contained in:
parent
8196b85408
commit
e90b573896
|
@ -54,16 +54,20 @@ enum vkd3d_shader_visibility
|
|||
|
||||
typedef uint64_t vkd3d_shader_hash_t;
|
||||
|
||||
enum vkd3d_shader_meta_flags
|
||||
{
|
||||
VKD3D_SHADER_META_FLAG_REPLACED = 1 << 0,
|
||||
VKD3D_SHADER_META_FLAG_USES_SUBGROUP_SIZE = 1 << 1,
|
||||
VKD3D_SHADER_META_FLAG_USES_NATIVE_16BIT_OPERATIONS = 1 << 2,
|
||||
};
|
||||
|
||||
struct vkd3d_shader_meta
|
||||
{
|
||||
vkd3d_shader_hash_t hash;
|
||||
unsigned int cs_workgroup_size[3]; /* Only contains valid data if uses_subgroup_size is true. */
|
||||
unsigned int patch_vertex_count; /* Relevant for HS. May be 0, in which case the patch vertex count is not known. */
|
||||
unsigned int cs_required_wave_size; /* If non-zero, force a specific CS subgroup size. */
|
||||
bool replaced;
|
||||
bool uses_subgroup_size;
|
||||
bool uses_native_16bit_operations;
|
||||
bool padding;
|
||||
uint32_t flags; /* vkd3d_shader_meta_flags */
|
||||
};
|
||||
STATIC_ASSERT(sizeof(struct vkd3d_shader_meta) == 32);
|
||||
|
||||
|
|
|
@ -526,7 +526,7 @@ int vkd3d_shader_compile_dxil(const struct vkd3d_shader_code *dxbc,
|
|||
spirv->meta.hash = hash;
|
||||
if (vkd3d_shader_replace(hash, &spirv->code, &spirv->size))
|
||||
{
|
||||
spirv->meta.replaced = true;
|
||||
spirv->meta.flags |= VKD3D_SHADER_META_FLAG_REPLACED;
|
||||
return ret;
|
||||
}
|
||||
quirks = vkd3d_shader_compile_arguments_select_quirks(compiler_args, hash);
|
||||
|
@ -859,15 +859,16 @@ int vkd3d_shader_compile_dxil(const struct vkd3d_shader_code *dxbc,
|
|||
memcpy(code, compiled.data, compiled.size);
|
||||
spirv->code = code;
|
||||
spirv->size = compiled.size;
|
||||
spirv->meta.uses_subgroup_size = dxil_spv_converter_uses_subgroup_size(converter) == DXIL_SPV_TRUE;
|
||||
if (dxil_spv_converter_uses_subgroup_size(converter) == DXIL_SPV_TRUE)
|
||||
spirv->meta.flags |= VKD3D_SHADER_META_FLAG_USES_SUBGROUP_SIZE;
|
||||
dxil_spv_converter_get_compute_workgroup_dimensions(converter,
|
||||
&spirv->meta.cs_workgroup_size[0],
|
||||
&spirv->meta.cs_workgroup_size[1],
|
||||
&spirv->meta.cs_workgroup_size[2]);
|
||||
dxil_spv_converter_get_patch_vertex_count(converter, &spirv->meta.patch_vertex_count);
|
||||
dxil_spv_converter_get_compute_required_wave_size(converter, &spirv->meta.cs_required_wave_size);
|
||||
spirv->meta.uses_native_16bit_operations = dxil_spv_converter_uses_shader_feature(converter,
|
||||
DXIL_SPV_SHADER_FEATURE_NATIVE_16BIT_OPERATIONS) == DXIL_SPV_TRUE;
|
||||
if (dxil_spv_converter_uses_shader_feature(converter, DXIL_SPV_SHADER_FEATURE_NATIVE_16BIT_OPERATIONS) == DXIL_SPV_TRUE)
|
||||
spirv->meta.flags |= VKD3D_SHADER_META_FLAG_USES_NATIVE_16BIT_OPERATIONS;
|
||||
|
||||
vkd3d_shader_dump_spirv_shader(hash, spirv);
|
||||
|
||||
|
@ -912,7 +913,7 @@ int vkd3d_shader_compile_dxil_export(const struct vkd3d_shader_code *dxil,
|
|||
{
|
||||
if (vkd3d_shader_replace_export(hash, &spirv->code, &spirv->size, demangled_export))
|
||||
{
|
||||
spirv->meta.replaced = true;
|
||||
spirv->meta.flags |= VKD3D_SHADER_META_FLAG_REPLACED;
|
||||
vkd3d_free(demangled_export);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1286,9 +1287,10 @@ int vkd3d_shader_compile_dxil_export(const struct vkd3d_shader_code *dxil,
|
|||
memcpy(code, compiled.data, compiled.size);
|
||||
spirv->code = code;
|
||||
spirv->size = compiled.size;
|
||||
spirv->meta.uses_subgroup_size = dxil_spv_converter_uses_subgroup_size(converter) == DXIL_SPV_TRUE;
|
||||
spirv->meta.uses_native_16bit_operations = dxil_spv_converter_uses_shader_feature(converter,
|
||||
DXIL_SPV_SHADER_FEATURE_NATIVE_16BIT_OPERATIONS) == DXIL_SPV_TRUE;
|
||||
if (dxil_spv_converter_uses_subgroup_size(converter) == DXIL_SPV_TRUE)
|
||||
spirv->meta.flags |= VKD3D_SHADER_META_FLAG_USES_SUBGROUP_SIZE;
|
||||
if (dxil_spv_converter_uses_shader_feature(converter, DXIL_SPV_SHADER_FEATURE_NATIVE_16BIT_OPERATIONS) == DXIL_SPV_TRUE)
|
||||
spirv->meta.flags |= VKD3D_SHADER_META_FLAG_USES_NATIVE_16BIT_OPERATIONS;
|
||||
|
||||
if (demangled_export)
|
||||
vkd3d_shader_dump_spirv_shader_export(hash, spirv, demangled_export);
|
||||
|
|
|
@ -349,7 +349,7 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
|||
spirv->meta.hash = hash;
|
||||
if (vkd3d_shader_replace(hash, &spirv->code, &spirv->size))
|
||||
{
|
||||
spirv->meta.replaced = true;
|
||||
spirv->meta.flags |= VKD3D_SHADER_META_FLAG_REPLACED;
|
||||
return VKD3D_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -6930,8 +6930,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_SetPipelineState(d3d12_command_
|
|||
for (i = 0; i < state->graphics.stage_count; i++)
|
||||
{
|
||||
TRACE("Binding graphics module with hash: %016"PRIx64" (replaced: %s).\n",
|
||||
state->graphics.stage_meta[i].hash,
|
||||
state->graphics.stage_meta[i].replaced ? "yes" : "no");
|
||||
state->graphics.stage_meta[i].hash,
|
||||
(state->graphics.stage_meta[i].flags & VKD3D_SHADER_META_FLAG_REPLACED) ? "yes" : "no");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5987,7 +5987,8 @@ out_free_mutex:
|
|||
bool d3d12_device_validate_shader_meta(struct d3d12_device *device, const struct vkd3d_shader_meta *meta)
|
||||
{
|
||||
/* TODO: Add more as required. */
|
||||
if (meta->uses_native_16bit_operations && !device->d3d12_caps.options4.Native16BitShaderOpsSupported)
|
||||
if ((meta->flags & VKD3D_SHADER_META_FLAG_USES_NATIVE_16BIT_OPERATIONS) &&
|
||||
!device->d3d12_caps.options4.Native16BitShaderOpsSupported)
|
||||
{
|
||||
WARN("Attempting to use 16-bit operations in shader %016"PRIx64", but this is not supported.", meta->hash);
|
||||
return false;
|
||||
|
|
|
@ -1130,7 +1130,7 @@ static HRESULT d3d12_state_object_compile_pipeline(struct d3d12_state_object *ob
|
|||
|
||||
stage->module = create_shader_module(object->device, spirv.code, spirv.size);
|
||||
|
||||
if (spirv.meta.uses_subgroup_size &&
|
||||
if ((spirv.meta.flags & VKD3D_SHADER_META_FLAG_USES_SUBGROUP_SIZE) &&
|
||||
object->device->device_info.subgroup_size_control_features.subgroupSizeControl)
|
||||
{
|
||||
stage->flags |= VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT;
|
||||
|
|
|
@ -2243,7 +2243,7 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
|
|||
if (!d3d12_device_validate_shader_meta(device, &spirv.meta))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if ((spirv.meta.uses_subgroup_size &&
|
||||
if (((spirv.meta.flags & VKD3D_SHADER_META_FLAG_USES_SUBGROUP_SIZE) &&
|
||||
device->device_info.subgroup_size_control_features.subgroupSizeControl) ||
|
||||
spirv.meta.cs_required_wave_size)
|
||||
{
|
||||
|
@ -2331,7 +2331,7 @@ static HRESULT vkd3d_create_compute_pipeline(struct d3d12_device *device,
|
|||
pipeline_info.basePipelineHandle = VK_NULL_HANDLE;
|
||||
pipeline_info.basePipelineIndex = -1;
|
||||
|
||||
if (meta->replaced && device->debug_ring.active)
|
||||
if ((meta->flags & VKD3D_SHADER_META_FLAG_REPLACED) && device->debug_ring.active)
|
||||
{
|
||||
vkd3d_shader_debug_ring_init_spec_constant(device, &spec_info, meta->hash);
|
||||
pipeline_info.stage.pSpecializationInfo = &spec_info.spec_info;
|
||||
|
@ -3483,7 +3483,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
|
|||
if (shader_stages[i].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT)
|
||||
graphics->patch_vertex_count = graphics->stage_meta[graphics->stage_count].patch_vertex_count;
|
||||
|
||||
if (graphics->stage_meta[graphics->stage_count].replaced && device->debug_ring.active)
|
||||
if ((graphics->stage_meta[graphics->stage_count].flags & VKD3D_SHADER_META_FLAG_REPLACED) &&
|
||||
device->debug_ring.active)
|
||||
{
|
||||
vkd3d_shader_debug_ring_init_spec_constant(device,
|
||||
&graphics->spec_info[graphics->stage_count],
|
||||
|
@ -3764,11 +3765,11 @@ bool d3d12_pipeline_state_has_replaced_shaders(struct d3d12_pipeline_state *stat
|
|||
{
|
||||
unsigned int i;
|
||||
if (state->vk_bind_point == VK_PIPELINE_BIND_POINT_COMPUTE)
|
||||
return state->compute.meta.replaced;
|
||||
return !!(state->compute.meta.flags & VKD3D_SHADER_META_FLAG_REPLACED);
|
||||
else if (state->vk_bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS)
|
||||
{
|
||||
for (i = 0; i < state->graphics.stage_count; i++)
|
||||
if (state->graphics.stage_meta[i].replaced)
|
||||
if (state->graphics.stage_meta[i].flags & VKD3D_SHADER_META_FLAG_REPLACED)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue