diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/broadcom/compiler/nir_to_vir.c | 20 | ||||
-rw-r--r-- | src/broadcom/compiler/v3d_compiler.h | 1 | ||||
-rw-r--r-- | src/broadcom/compiler/vir_dump.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3d_screen.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3d_uniforms.c | 5 |
5 files changed, 22 insertions, 11 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index e2407f787c7..846a2a704af 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -219,6 +219,10 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr, } } + uint32_t const_offset = 0; + if (nir_src_is_const(instr->src[offset_src])) + const_offset = nir_src_as_uint(instr->src[offset_src]); + /* Make sure we won't exceed the 16-entry TMU fifo if each thread is * storing at the same time. */ @@ -227,8 +231,6 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr, struct qreg offset; if (instr->intrinsic == nir_intrinsic_load_uniform) { - offset = vir_uniform(c, QUNIFORM_UBO_ADDR, 0); - /* Find what variable in the default uniform block this * uniform load is coming from. */ @@ -252,16 +254,19 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr, c->next_ubo_dst_offset += range->size; } - base = base - range->src_offset + range->dst_offset; + const_offset += base - range->src_offset + range->dst_offset; - if (base != 0) - offset = vir_ADD(c, offset, vir_uniform_ui(c, base)); + offset = vir_uniform(c, QUNIFORM_UBO_ADDR, + v3d_unit_data_create(0, const_offset)); + const_offset = 0; } else if (instr->intrinsic == nir_intrinsic_load_ubo) { + uint32_t index = nir_src_as_uint(instr->src[0]) + 1; /* Note that QUNIFORM_UBO_ADDR takes a UBO index shifted up by * 1 (0 is gallium's constant buffer 0). */ offset = vir_uniform(c, QUNIFORM_UBO_ADDR, - nir_src_as_uint(instr->src[0]) + 1); + v3d_unit_data_create(index, const_offset)); + const_offset = 0; } else if (is_shared) { /* Shared variables have no buffer index, and all start from a * common base that we set up at the start of dispatch @@ -295,8 +300,7 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr, dest = vir_reg(QFILE_MAGIC, V3D_QPU_WADDR_TMUAU); struct qinst *tmu; - if (nir_src_is_const(instr->src[offset_src]) && - nir_src_as_uint(instr->src[offset_src]) == 0) { + if (nir_src_is_const(instr->src[offset_src]) && const_offset == 0) { tmu = vir_MOV_dest(c, dest, offset); } else { tmu = vir_ADD_dest(c, dest, diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h index 81307e0996f..d8d916fb14b 100644 --- a/src/broadcom/compiler/v3d_compiler.h +++ b/src/broadcom/compiler/v3d_compiler.h @@ -283,6 +283,7 @@ enum quniform_contents { static inline uint32_t v3d_unit_data_create(uint32_t unit, uint32_t value) { + assert(value < (1 << 24)); return unit << 24 | value; } diff --git a/src/broadcom/compiler/vir_dump.c b/src/broadcom/compiler/vir_dump.c index be98539b0be..e8a2879fbe2 100644 --- a/src/broadcom/compiler/vir_dump.c +++ b/src/broadcom/compiler/vir_dump.c @@ -99,7 +99,9 @@ vir_dump_uniform(enum quniform_contents contents, break; case QUNIFORM_UBO_ADDR: - fprintf(stderr, "ubo[%d]", data); + fprintf(stderr, "ubo[%d]+0x%x", + v3d_unit_data_get_unit(data), + v3d_unit_data_get_offset(data)); break; case QUNIFORM_SSBO_OFFSET: diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c index c810fbc98b4..073bdf51449 100644 --- a/src/gallium/drivers/v3d/v3d_screen.c +++ b/src/gallium/drivers/v3d/v3d_screen.c @@ -279,6 +279,9 @@ v3d_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_MAX_TEMPS: return 256; /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE: + /* Note: Limited by the offset size in + * v3d_unit_data_create(). + */ return 16 * 1024 * sizeof(float); case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: return 16; diff --git a/src/gallium/drivers/v3d/v3d_uniforms.c b/src/gallium/drivers/v3d/v3d_uniforms.c index 371568b31e6..b48f6526d61 100644 --- a/src/gallium/drivers/v3d/v3d_uniforms.c +++ b/src/gallium/drivers/v3d/v3d_uniforms.c @@ -334,13 +334,14 @@ v3d_write_uniforms(struct v3d_context *v3d, struct v3d_compiled_shader *shader, cl_aligned_reloc(&job->indirect, &uniforms, ubo, 0); } else { - int ubo_index = data; + int ubo_index = v3d_unit_data_get_unit(data); struct v3d_resource *rsc = v3d_resource(cb->cb[ubo_index].buffer); cl_aligned_reloc(&job->indirect, &uniforms, rsc->bo, - cb->cb[ubo_index].buffer_offset); + cb->cb[ubo_index].buffer_offset + + v3d_unit_data_get_offset(data)); } break; |