mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
hk: use #defines for uniforms
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35658>
This commit is contained in:
parent
53bbd850f5
commit
3afd675310
3 changed files with 25 additions and 20 deletions
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
#include "hk_cmd_buffer.h"
|
||||
|
||||
#include "agx_abi.h"
|
||||
#include "agx_bo.h"
|
||||
#include "agx_device.h"
|
||||
#include "agx_linker.h"
|
||||
|
|
@ -665,23 +666,27 @@ hk_upload_usc_words(struct hk_cmd_buffer *cmd, struct hk_shader *s,
|
|||
|
||||
if (count) {
|
||||
agx_usc_uniform(
|
||||
&b, 0, 4 * count,
|
||||
&b, AGX_ABI_VUNI_VBO_BASE(0), 4 * count,
|
||||
root_ptr + hk_root_descriptor_offset(draw.attrib_base));
|
||||
|
||||
agx_usc_uniform(
|
||||
&b, 4 * count, 2 * count,
|
||||
&b, AGX_ABI_VUNI_VBO_CLAMP(count, 0), 2 * count,
|
||||
root_ptr + hk_root_descriptor_offset(draw.attrib_clamps));
|
||||
}
|
||||
|
||||
if (cmd->state.gfx.draw_params)
|
||||
agx_usc_uniform(&b, 6 * count, 4, cmd->state.gfx.draw_params);
|
||||
if (cmd->state.gfx.draw_params) {
|
||||
agx_usc_uniform(&b, AGX_ABI_VUNI_FIRST_VERTEX(count), 4,
|
||||
cmd->state.gfx.draw_params);
|
||||
}
|
||||
|
||||
if (cmd->state.gfx.draw_id_ptr)
|
||||
agx_usc_uniform(&b, (6 * count) + 4, 1, cmd->state.gfx.draw_id_ptr);
|
||||
if (cmd->state.gfx.draw_id_ptr) {
|
||||
agx_usc_uniform(&b, AGX_ABI_VUNI_DRAW_ID(count), 1,
|
||||
cmd->state.gfx.draw_id_ptr);
|
||||
}
|
||||
|
||||
if (linked->sw_indexing) {
|
||||
agx_usc_uniform(
|
||||
&b, (6 * count) + 8, 4,
|
||||
&b, AGX_ABI_VUNI_INPUT_ASSEMBLY(count), 4,
|
||||
root_ptr + hk_root_descriptor_offset(draw.input_assembly));
|
||||
}
|
||||
} else if (sw_stage == MESA_SHADER_FRAGMENT) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
#include "pipe/p_defines.h"
|
||||
#include "vulkan/vulkan_core.h"
|
||||
#include "agx_abi.h"
|
||||
#include "agx_nir_texture.h"
|
||||
#include "hk_cmd_buffer.h"
|
||||
#include "hk_descriptor_set.h"
|
||||
|
|
@ -390,7 +391,7 @@ translate_pipeline_stat_bit(enum pipe_statistics_query_index pipe)
|
|||
static bool
|
||||
lower_uvs_index(nir_builder *b, nir_intrinsic_instr *intrin, void *data)
|
||||
{
|
||||
unsigned *vs_uniform_base = data;
|
||||
unsigned *nr_vbos = data;
|
||||
|
||||
switch (intrin->intrinsic) {
|
||||
case nir_intrinsic_load_uvs_index_agx: {
|
||||
|
|
@ -450,17 +451,17 @@ lower_uvs_index(nir_builder *b, nir_intrinsic_instr *intrin, void *data)
|
|||
case nir_intrinsic_load_input_assembly_buffer_agx: {
|
||||
b->cursor = nir_instr_remove(&intrin->instr);
|
||||
|
||||
unsigned base = *vs_uniform_base;
|
||||
unsigned base = AGX_ABI_VUNI_FIRST_VERTEX(*nr_vbos);
|
||||
unsigned size = 32;
|
||||
|
||||
if (intrin->intrinsic == nir_intrinsic_load_base_instance) {
|
||||
base += 2;
|
||||
base = AGX_ABI_VUNI_BASE_INSTANCE(*nr_vbos);
|
||||
} else if (intrin->intrinsic == nir_intrinsic_load_draw_id) {
|
||||
base += 4;
|
||||
base = AGX_ABI_VUNI_DRAW_ID(*nr_vbos);
|
||||
size = 16;
|
||||
} else if (intrin->intrinsic ==
|
||||
nir_intrinsic_load_input_assembly_buffer_agx) {
|
||||
base += 8;
|
||||
base = AGX_ABI_VUNI_INPUT_ASSEMBLY(*nr_vbos);
|
||||
size = 64;
|
||||
}
|
||||
|
||||
|
|
@ -520,10 +521,10 @@ lower_uvs_index(nir_builder *b, nir_intrinsic_instr *intrin, void *data)
|
|||
}
|
||||
|
||||
bool
|
||||
hk_lower_uvs_index(nir_shader *s, unsigned vs_uniform_base)
|
||||
hk_lower_uvs_index(nir_shader *s, unsigned nr_vbos)
|
||||
{
|
||||
return nir_shader_intrinsics_pass(
|
||||
s, lower_uvs_index, nir_metadata_control_flow, &vs_uniform_base);
|
||||
return nir_shader_intrinsics_pass(s, lower_uvs_index,
|
||||
nir_metadata_control_flow, &nr_vbos);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
|
|
@ -866,13 +866,12 @@ hk_compile_nir(struct hk_device *dev, const VkAllocationCallbacks *pAllocator,
|
|||
const struct hk_fs_key *fs_key, struct hk_shader *shader,
|
||||
gl_shader_stage sw_stage, bool hw, nir_xfb_info *xfb_info)
|
||||
{
|
||||
unsigned vs_uniform_base = 0;
|
||||
unsigned nr_vbos = 0;
|
||||
|
||||
/* For now, only shader objects are supported */
|
||||
if (sw_stage == MESA_SHADER_VERTEX) {
|
||||
vs_uniform_base =
|
||||
6 * DIV_ROUND_UP(
|
||||
BITSET_LAST_BIT(shader->info.vs.attrib_components_read), 4);
|
||||
nr_vbos = DIV_ROUND_UP(
|
||||
BITSET_LAST_BIT(shader->info.vs.attrib_components_read), 4);
|
||||
} else if (sw_stage == MESA_SHADER_FRAGMENT) {
|
||||
shader->info.fs.interp = agx_gather_interp_info(nir);
|
||||
shader->info.fs.writes_memory = nir->info.writes_memory;
|
||||
|
|
@ -929,7 +928,7 @@ hk_compile_nir(struct hk_device *dev, const VkAllocationCallbacks *pAllocator,
|
|||
}
|
||||
|
||||
/* XXX: rename */
|
||||
NIR_PASS(_, nir, hk_lower_uvs_index, vs_uniform_base);
|
||||
NIR_PASS(_, nir, hk_lower_uvs_index, nr_vbos);
|
||||
|
||||
#if 0
|
||||
/* TODO */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue