mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 05:08:08 +02:00
v3d/compiler: handle GL/Vulkan differences in uniform handling
This also adds a v3d_execution_environment, so compiler could know if it is generating code for OpenGL or Vulkan needs. Reviewed-by: Iago Toral <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
parent
4e2817fd33
commit
c8212731e7
4 changed files with 22 additions and 4 deletions
|
|
@ -241,10 +241,13 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr,
|
||||||
v3d_unit_data_create(0, const_offset));
|
v3d_unit_data_create(0, const_offset));
|
||||||
const_offset = 0;
|
const_offset = 0;
|
||||||
} else if (instr->intrinsic == nir_intrinsic_load_ubo) {
|
} else if (instr->intrinsic == nir_intrinsic_load_ubo) {
|
||||||
uint32_t index = nir_src_as_uint(instr->src[0]) + 1;
|
uint32_t index = nir_src_as_uint(instr->src[0]);
|
||||||
/* Note that QUNIFORM_UBO_ADDR takes a UBO index shifted up by
|
/* On OpenGL QUNIFORM_UBO_ADDR takes a UBO index
|
||||||
* 1 (0 is gallium's constant buffer 0).
|
* shifted up by 1 (0 is gallium's constant buffer 0).
|
||||||
*/
|
*/
|
||||||
|
if (c->key->environment == V3D_ENVIRONMENT_OPENGL)
|
||||||
|
index++;
|
||||||
|
|
||||||
base_offset =
|
base_offset =
|
||||||
vir_uniform(c, QUNIFORM_UBO_ADDR,
|
vir_uniform(c, QUNIFORM_UBO_ADDR,
|
||||||
v3d_unit_data_create(index, const_offset));
|
v3d_unit_data_create(index, const_offset));
|
||||||
|
|
|
||||||
|
|
@ -333,6 +333,11 @@ static inline uint8_t v3d_slot_get_component(struct v3d_varying_slot slot)
|
||||||
return slot.slot_and_component & 3;
|
return slot.slot_and_component & 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum v3d_execution_environment {
|
||||||
|
V3D_ENVIRONMENT_OPENGL = 0,
|
||||||
|
V3D_ENVIRONMENT_VULKAN,
|
||||||
|
};
|
||||||
|
|
||||||
struct v3d_key {
|
struct v3d_key {
|
||||||
void *shader_state;
|
void *shader_state;
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -346,6 +351,8 @@ struct v3d_key {
|
||||||
uint8_t num_tex_used;
|
uint8_t num_tex_used;
|
||||||
uint8_t ucp_enables;
|
uint8_t ucp_enables;
|
||||||
bool is_last_geometry_stage;
|
bool is_last_geometry_stage;
|
||||||
|
|
||||||
|
enum v3d_execution_environment environment;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct v3d_fs_key {
|
struct v3d_fs_key {
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,12 @@ static void
|
||||||
v3d_nir_lower_uniform(struct v3d_compile *c, nir_builder *b,
|
v3d_nir_lower_uniform(struct v3d_compile *c, nir_builder *b,
|
||||||
nir_intrinsic_instr *intr)
|
nir_intrinsic_instr *intr)
|
||||||
{
|
{
|
||||||
|
/* On SPIR-V/Vulkan we are already getting our offsets in
|
||||||
|
* bytes.
|
||||||
|
*/
|
||||||
|
if (c->key->environment == V3D_ENVIRONMENT_VULKAN)
|
||||||
|
return;
|
||||||
|
|
||||||
b->cursor = nir_before_instr(&intr->instr);
|
b->cursor = nir_before_instr(&intr->instr);
|
||||||
|
|
||||||
nir_intrinsic_set_base(intr, nir_intrinsic_base(intr) * 16);
|
nir_intrinsic_set_base(intr, nir_intrinsic_base(intr) * 16);
|
||||||
|
|
|
||||||
|
|
@ -454,6 +454,8 @@ pipeline_populate_v3d_key(struct v3d_key *key,
|
||||||
* revisited based on all the clip related extensions available.
|
* revisited based on all the clip related extensions available.
|
||||||
*/
|
*/
|
||||||
key->ucp_enables = 0;
|
key->ucp_enables = 0;
|
||||||
|
|
||||||
|
key->environment = V3D_ENVIRONMENT_VULKAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: anv maps to hw primitive type. Perhaps eventually we would do the
|
/* FIXME: anv maps to hw primitive type. Perhaps eventually we would do the
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue