瀏覽代碼

radeonsi: (User) SGPR related cleanups.

Use the same user SGPRs for the same purpose in vertex and pixel shaders.

Better calculation of the number of SGPRs to reserve.
tags/i965-primitive-restart-v2
Michel Dänzer 13 年之前
父節點
當前提交
9918fbd026

+ 22
- 8
src/gallium/drivers/radeonsi/evergreen_state.c 查看文件

struct r600_pipe_state *rstate = &shader->rstate; struct r600_pipe_state *rstate = &shader->rstate;
struct r600_shader *rshader = &shader->shader; struct r600_shader *rshader = &shader->shader;
unsigned i, exports_ps, num_cout, spi_ps_in_control, db_shader_control; unsigned i, exports_ps, num_cout, spi_ps_in_control, db_shader_control;
unsigned num_sgprs, num_user_sgprs;
int pos_index = -1, face_index = -1; int pos_index = -1, face_index = -1;
int ninterp = 0; int ninterp = 0;
boolean have_linear = FALSE, have_centroid = FALSE, have_perspective = FALSE; boolean have_linear = FALSE, have_centroid = FALSE, have_perspective = FALSE;
va >> 40, va >> 40,
shader->bo, RADEON_USAGE_READ); shader->bo, RADEON_USAGE_READ);


num_user_sgprs = 6;
num_sgprs = shader->num_sgprs;
if (num_user_sgprs > num_sgprs)
num_sgprs = num_user_sgprs;
/* Last 2 reserved SGPRs are used for VCC */ /* Last 2 reserved SGPRs are used for VCC */
/* XXX: Hard-coding 2 SGPRs for constant buffer */
num_sgprs += 2;
assert(num_sgprs <= 104);

r600_pipe_state_add_reg(rstate, r600_pipe_state_add_reg(rstate,
R_00B028_SPI_SHADER_PGM_RSRC1_PS, R_00B028_SPI_SHADER_PGM_RSRC1_PS,
S_00B028_VGPRS(shader->num_vgprs / 4) |
S_00B028_SGPRS((shader->num_sgprs + 2 + 2 + 1) / 8),
S_00B028_VGPRS((shader->num_vgprs - 1) / 4) |
S_00B028_SGPRS((num_sgprs - 1) / 8),
NULL, 0); NULL, 0);
r600_pipe_state_add_reg(rstate, r600_pipe_state_add_reg(rstate,
R_00B02C_SPI_SHADER_PGM_RSRC2_PS, R_00B02C_SPI_SHADER_PGM_RSRC2_PS,
S_00B02C_USER_SGPR(6),
S_00B02C_USER_SGPR(num_user_sgprs),
NULL, 0); NULL, 0);


r600_pipe_state_add_reg(rstate, R_02880C_DB_SHADER_CONTROL, r600_pipe_state_add_reg(rstate, R_02880C_DB_SHADER_CONTROL,
struct r600_context *rctx = (struct r600_context *)ctx; struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_pipe_state *rstate = &shader->rstate; struct r600_pipe_state *rstate = &shader->rstate;
struct r600_shader *rshader = &shader->shader; struct r600_shader *rshader = &shader->shader;
unsigned num_sgprs, num_user_sgprs;
unsigned nparams, i; unsigned nparams, i;
uint64_t va; uint64_t va;


va >> 40, va >> 40,
shader->bo, RADEON_USAGE_READ); shader->bo, RADEON_USAGE_READ);


num_user_sgprs = 8;
num_sgprs = shader->num_sgprs;
if (num_user_sgprs > num_sgprs)
num_sgprs = num_user_sgprs;
/* Last 2 reserved SGPRs are used for VCC */ /* Last 2 reserved SGPRs are used for VCC */
/* XXX: Hard-coding 2 SGPRs for constant buffer */
num_sgprs += 2;
assert(num_sgprs <= 104);

r600_pipe_state_add_reg(rstate, r600_pipe_state_add_reg(rstate,
R_00B128_SPI_SHADER_PGM_RSRC1_VS, R_00B128_SPI_SHADER_PGM_RSRC1_VS,
S_00B128_VGPRS(shader->num_vgprs / 4) |
S_00B128_SGPRS((shader->num_sgprs + 2 + 2 + 2) / 8),
S_00B128_VGPRS((shader->num_vgprs - 1) / 4) |
S_00B128_SGPRS((num_sgprs - 1) / 8),
NULL, 0); NULL, 0);
r600_pipe_state_add_reg(rstate, r600_pipe_state_add_reg(rstate,
R_00B12C_SPI_SHADER_PGM_RSRC2_VS, R_00B12C_SPI_SHADER_PGM_RSRC2_VS,
S_00B12C_USER_SGPR(2 + 2),
S_00B12C_USER_SGPR(num_user_sgprs),
NULL, 0); NULL, 0);
} }



+ 4
- 4
src/gallium/drivers/radeonsi/r600_state_common.c 查看文件

rstate = &rctx->vs_const_buffer; rstate = &rctx->vs_const_buffer;
rstate->nregs = 0; rstate->nregs = 0;
r600_pipe_state_add_reg(rstate, r600_pipe_state_add_reg(rstate,
R_00B138_SPI_SHADER_USER_DATA_VS_2,
R_00B130_SPI_SHADER_USER_DATA_VS_0,
va_offset, rbuffer, RADEON_USAGE_READ); va_offset, rbuffer, RADEON_USAGE_READ);
r600_pipe_state_add_reg(rstate, r600_pipe_state_add_reg(rstate,
R_00B13C_SPI_SHADER_USER_DATA_VS_3,
R_00B134_SPI_SHADER_USER_DATA_VS_1,
va_offset >> 32, NULL, 0); va_offset >> 32, NULL, 0);
break; break;
case PIPE_SHADER_FRAGMENT: case PIPE_SHADER_FRAGMENT:


va = r600_resource_va(ctx->screen, (void*)t_list_buffer); va = r600_resource_va(ctx->screen, (void*)t_list_buffer);
r600_pipe_state_add_reg(rstate, r600_pipe_state_add_reg(rstate,
R_00B130_SPI_SHADER_USER_DATA_VS_0,
R_00B148_SPI_SHADER_USER_DATA_VS_6,
va, t_list_buffer, RADEON_USAGE_READ); va, t_list_buffer, RADEON_USAGE_READ);
r600_pipe_state_add_reg(rstate, r600_pipe_state_add_reg(rstate,
R_00B134_SPI_SHADER_USER_DATA_VS_1,
R_00B14C_SPI_SHADER_USER_DATA_VS_7,
va >> 32, va >> 32,
NULL, 0); NULL, 0);



+ 7
- 4
src/gallium/drivers/radeonsi/radeonsi_shader.c 查看文件

unsigned chan; unsigned chan;


/* XXX: Communicate with the rest of the driver about which SGPR the T# /* XXX: Communicate with the rest of the driver about which SGPR the T#
* list pointer is going to be stored in. Hard code to SGPR[0-1] for
* list pointer is going to be stored in. Hard code to SGPR[6:7] for
* now */ * now */
t_list_ptr = use_sgpr(base->gallivm, SGPR_I64, 0);
t_list_ptr = use_sgpr(base->gallivm, SGPR_I64, 3);


t_offset = lp_build_const_int32(base->gallivm, t_offset = lp_build_const_int32(base->gallivm,
4 * velem->vertex_buffer_index); 4 * velem->vertex_buffer_index);
* [32:16] ParamOffset * [32:16] ParamOffset
* *
*/ */
/* XXX: This register number must be identical to the S_00B02C_USER_SGPR
* register field value
*/
LLVMValueRef params = use_sgpr(base->gallivm, SGPR_I32, 6); LLVMValueRef params = use_sgpr(base->gallivm, SGPR_I32, 6);




LLVMValueRef offset; LLVMValueRef offset;


/* XXX: Assume the pointer to the constant buffer is being stored in /* XXX: Assume the pointer to the constant buffer is being stored in
* SGPR[2:3] */
const_ptr = use_sgpr(base->gallivm, SGPR_I64, 1);
* SGPR[0:1] */
const_ptr = use_sgpr(base->gallivm, SGPR_I64, 0);


/* XXX: This assumes that the constant buffer is not packed, so /* XXX: This assumes that the constant buffer is not packed, so
* CONST[0].x will have an offset of 0 and CONST[1].x will have an * CONST[0].x will have an offset of 0 and CONST[1].x will have an

Loading…
取消
儲存