mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 20:28:04 +02:00
microsoft/compiler: Refactor type -> resource kind helper
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21913>
This commit is contained in:
parent
a838f095ef
commit
abc2412ccc
2 changed files with 38 additions and 31 deletions
|
|
@ -75,6 +75,38 @@ enum dxil_component_type dxil_get_comp_type(const struct glsl_type *type)
|
|||
}
|
||||
}
|
||||
|
||||
enum dxil_resource_kind dxil_sampler_dim_to_resource_kind(enum glsl_sampler_dim dim, bool is_array)
|
||||
{
|
||||
switch (dim) {
|
||||
case GLSL_SAMPLER_DIM_1D:
|
||||
return is_array ? DXIL_RESOURCE_KIND_TEXTURE1D_ARRAY
|
||||
: DXIL_RESOURCE_KIND_TEXTURE1D;
|
||||
case GLSL_SAMPLER_DIM_2D:
|
||||
case GLSL_SAMPLER_DIM_EXTERNAL:
|
||||
return is_array ? DXIL_RESOURCE_KIND_TEXTURE2D_ARRAY
|
||||
: DXIL_RESOURCE_KIND_TEXTURE2D;
|
||||
case GLSL_SAMPLER_DIM_SUBPASS:
|
||||
return DXIL_RESOURCE_KIND_TEXTURE2D_ARRAY;
|
||||
case GLSL_SAMPLER_DIM_3D:
|
||||
return DXIL_RESOURCE_KIND_TEXTURE3D;
|
||||
case GLSL_SAMPLER_DIM_CUBE:
|
||||
return is_array ? DXIL_RESOURCE_KIND_TEXTURECUBE_ARRAY
|
||||
: DXIL_RESOURCE_KIND_TEXTURECUBE;
|
||||
case GLSL_SAMPLER_DIM_RECT:
|
||||
return DXIL_RESOURCE_KIND_TEXTURE2D;
|
||||
case GLSL_SAMPLER_DIM_BUF:
|
||||
return DXIL_RESOURCE_KIND_TYPED_BUFFER;
|
||||
case GLSL_SAMPLER_DIM_MS:
|
||||
return is_array ? DXIL_RESOURCE_KIND_TEXTURE2DMS_ARRAY
|
||||
: DXIL_RESOURCE_KIND_TEXTURE2DMS;
|
||||
case GLSL_SAMPLER_DIM_SUBPASS_MS:
|
||||
return DXIL_RESOURCE_KIND_TEXTURE2DMS_ARRAY;
|
||||
|
||||
default:
|
||||
unreachable("unexpected sampler type");
|
||||
}
|
||||
}
|
||||
|
||||
enum dxil_resource_kind dxil_get_resource_kind(const struct glsl_type *type)
|
||||
{
|
||||
type = glsl_without_array(type);
|
||||
|
|
@ -83,37 +115,8 @@ enum dxil_resource_kind dxil_get_resource_kind(const struct glsl_type *type)
|
|||
* an array, key is the first refers to sampler[] and the second to samplerArray */
|
||||
bool is_array = glsl_sampler_type_is_array(type);
|
||||
|
||||
if (glsl_type_is_texture(type) || glsl_type_is_image(type)) {
|
||||
switch (glsl_get_sampler_dim(type)) {
|
||||
case GLSL_SAMPLER_DIM_1D:
|
||||
return is_array ? DXIL_RESOURCE_KIND_TEXTURE1D_ARRAY
|
||||
: DXIL_RESOURCE_KIND_TEXTURE1D;
|
||||
case GLSL_SAMPLER_DIM_2D:
|
||||
case GLSL_SAMPLER_DIM_EXTERNAL:
|
||||
return is_array ? DXIL_RESOURCE_KIND_TEXTURE2D_ARRAY
|
||||
: DXIL_RESOURCE_KIND_TEXTURE2D;
|
||||
case GLSL_SAMPLER_DIM_SUBPASS:
|
||||
return DXIL_RESOURCE_KIND_TEXTURE2D_ARRAY;
|
||||
case GLSL_SAMPLER_DIM_3D:
|
||||
return DXIL_RESOURCE_KIND_TEXTURE3D;
|
||||
case GLSL_SAMPLER_DIM_CUBE:
|
||||
return is_array ? DXIL_RESOURCE_KIND_TEXTURECUBE_ARRAY
|
||||
: DXIL_RESOURCE_KIND_TEXTURECUBE;
|
||||
case GLSL_SAMPLER_DIM_RECT:
|
||||
return DXIL_RESOURCE_KIND_TEXTURE2D;
|
||||
case GLSL_SAMPLER_DIM_BUF:
|
||||
return DXIL_RESOURCE_KIND_TYPED_BUFFER;
|
||||
case GLSL_SAMPLER_DIM_MS:
|
||||
return is_array ? DXIL_RESOURCE_KIND_TEXTURE2DMS_ARRAY
|
||||
: DXIL_RESOURCE_KIND_TEXTURE2DMS;
|
||||
case GLSL_SAMPLER_DIM_SUBPASS_MS:
|
||||
return DXIL_RESOURCE_KIND_TEXTURE2DMS_ARRAY;
|
||||
|
||||
default:
|
||||
debug_printf("type: %s\n", glsl_get_type_name(type));
|
||||
unreachable("unexpected sampler type");
|
||||
}
|
||||
}
|
||||
if (glsl_type_is_texture(type) || glsl_type_is_image(type))
|
||||
return dxil_sampler_dim_to_resource_kind(glsl_get_sampler_dim(type), is_array);
|
||||
|
||||
debug_printf("type: %s\n", glsl_get_type_name(type));
|
||||
unreachable("unexpected glsl type");
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
#ifndef DIXL_ENUMS_H
|
||||
#define DIXL_ENUMS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
enum dxil_signature_kind {
|
||||
DXIL_SIG_INVALID = 0,
|
||||
DXIL_SIG_INPUT,
|
||||
|
|
@ -372,11 +374,13 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
struct glsl_type;
|
||||
enum glsl_sampler_dim;
|
||||
|
||||
enum dxil_component_type dxil_get_comp_type(const struct glsl_type *type);
|
||||
|
||||
enum dxil_prog_sig_comp_type dxil_get_prog_sig_comp_type(const struct glsl_type *type);
|
||||
|
||||
enum dxil_resource_kind dxil_sampler_dim_to_resource_kind(enum glsl_sampler_dim dim, bool is_array);
|
||||
enum dxil_resource_kind dxil_get_resource_kind(const struct glsl_type *type);
|
||||
|
||||
enum dxil_primitive_topology dxil_get_primitive_topology(unsigned topology);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue