Re: [Mesa-dev] [PATCH 1/2] r600g: precalculate semantic indices for SPI setup
On Sat, Nov 5, 2011 at 1:10 AM, Vadim Girlin vadimgir...@gmail.com wrote: On Fri, 2011-11-04 at 22:53 +0100, Marek Olšák wrote: FYI, this commit completely breaks RV670. glxgears is completely black, other apps are either black or rendered incorrectly (mostly one-colored, the clear color I guess). Thanks. Probably it's due to missing spi_vs_out_id array initialization in the r600_pipe_shader_vs - I forgot this when I was reproducing evergreen changes for r600. Unfortunately, I have no r600 hw to test it myself. I'll resend fixed patch when I will be completely sure. I'd be grateful if you could confirm that this change for r600_pipe_shader_vs helps (or not): - unsigned spi_vs_out_id[10]; + unsigned spi_vs_out_id[10] = {}; Yup, that fixes it. Thanks! Alex Vadim ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] r600g: precalculate semantic indices for SPI setup
There is no need to duplicate semantic mapping which is done in hw, so get rid of r600_find_vs_semantic_index. TGSI name/sid pair is mapped to the 8-bit semantic index for SPI. Signed-off-by: Vadim Girlin vadimgir...@gmail.com --- This patch and the next one were tested on the evergreen, there are some changes in the test results: Following tests are passing due to slightly different handling of TGSI_SEMANTIC_BCOLOR (it's still not completely correct). vertex-program-two-side enabled back back2 fail - pass vertex-program-two-side enabled back front2 fail - pass vertex-program-two-side enabled front back2 fail - pass This test usually fails for me after these patches, but passes when it's run independently - probably unrelated: time-elapsedpass - fail src/gallium/drivers/r600/evergreen_state.c | 19 src/gallium/drivers/r600/r600_shader.c | 67 -- src/gallium/drivers/r600/r600_shader.h |2 +- src/gallium/drivers/r600/r600_state.c| 20 +++- src/gallium/drivers/r600/r600_state_common.c | 13 ++--- 5 files changed, 64 insertions(+), 57 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index fd2e5da..904267d 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2375,20 +2375,20 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; struct r600_pipe_state *rstate = shader-rstate; struct r600_shader *rshader = shader-shader; - unsigned spi_vs_out_id[10]; - unsigned i, tmp, nparams; + unsigned spi_vs_out_id[10] = {}; + unsigned i, tmp, nparams = 0; /* clear previous register */ rstate-nregs = 0; - /* so far never got proper semantic id from tgsi */ - for (i = 0; i 10; i++) { - spi_vs_out_id[i] = 0; - } - for (i = 0; i 32; i++) { - tmp = i ((i 3) * 8); - spi_vs_out_id[i / 4] |= tmp; + for (i = 0; i rshader-noutput; i++) { + if (rshader-output[i].spi_sid) { + tmp = rshader-output[i].spi_sid ((nparams 3) * 8); + spi_vs_out_id[nparams / 4] |= tmp; + nparams++; + } } + for (i = 0; i 10; i++) { r600_pipe_state_add_reg(rstate, R_02861C_SPI_VS_OUT_ID_0 + i * 4, @@ -2399,7 +2399,6 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader * VS is required to export at least one param and r600_shader_from_tgsi() * takes care of adding a dummy export. */ - nparams = rshader-noutput - rshader-npos; if (nparams 1) nparams = 1; diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 87164ce..448e03a 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -57,24 +57,6 @@ issued in the w slot as well. The compiler must issue the source argument to slots z, y, and x */ - -int r600_find_vs_semantic_index(struct r600_shader *vs, - struct r600_shader *ps, int id) -{ - struct r600_shader_io *input = ps-input[id]; - int index = 0; - - for (int i = 0; i vs-noutput; i++) { - if (input-name == vs-output[i].name - input-sid == vs-output[i].sid) - return index; - else if (vs-output[i].name != TGSI_SEMANTIC_POSITION -vs-output[i].name != TGSI_SEMANTIC_PSIZE) - index++; - } - return 0; -} - static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *shader) { struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; @@ -361,6 +343,44 @@ static int evergreen_interp_flat(struct r600_shader_ctx *ctx, int input) * DB_SOURCE_FORMAT - export control restrictions * */ + + +/* Map name/sid pair from tgsi to the 8-bit semantic index for SPI setup */ +static int r600_spi_sid(struct r600_shader_io * io) +{ + int index, name = io-name; + + /* These params are handled differently, they don't need +* semantic indices, so we'll use 0 for them. +*/ + if (name == TGSI_SEMANTIC_POSITION || + name == TGSI_SEMANTIC_PSIZE || + name == TGSI_SEMANTIC_FACE) + index = 0; + else { + if (name == TGSI_SEMANTIC_GENERIC) { + /* For generic params simply use sid from tgsi */ + index = io-sid; + } else { + + /* FIXME: two-side rendering is
Re: [Mesa-dev] [PATCH 1/2] r600g: precalculate semantic indices for SPI setup
On Fri, Nov 4, 2011 at 1:24 PM, Vadim Girlin vadimgir...@gmail.com wrote: There is no need to duplicate semantic mapping which is done in hw, so get rid of r600_find_vs_semantic_index. TGSI name/sid pair is mapped to the 8-bit semantic index for SPI. Pushed. Thanks! Note that the hw can use semantic ids for vertex fetch as well. Alex Signed-off-by: Vadim Girlin vadimgir...@gmail.com --- This patch and the next one were tested on the evergreen, there are some changes in the test results: Following tests are passing due to slightly different handling of TGSI_SEMANTIC_BCOLOR (it's still not completely correct). vertex-program-two-side enabled back back2 fail - pass vertex-program-two-side enabled back front2 fail - pass vertex-program-two-side enabled front back2 fail - pass This test usually fails for me after these patches, but passes when it's run independently - probably unrelated: time-elapsed pass - fail src/gallium/drivers/r600/evergreen_state.c | 19 src/gallium/drivers/r600/r600_shader.c | 67 -- src/gallium/drivers/r600/r600_shader.h | 2 +- src/gallium/drivers/r600/r600_state.c | 20 +++- src/gallium/drivers/r600/r600_state_common.c | 13 ++--- 5 files changed, 64 insertions(+), 57 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index fd2e5da..904267d 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2375,20 +2375,20 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; struct r600_pipe_state *rstate = shader-rstate; struct r600_shader *rshader = shader-shader; - unsigned spi_vs_out_id[10]; - unsigned i, tmp, nparams; + unsigned spi_vs_out_id[10] = {}; + unsigned i, tmp, nparams = 0; /* clear previous register */ rstate-nregs = 0; - /* so far never got proper semantic id from tgsi */ - for (i = 0; i 10; i++) { - spi_vs_out_id[i] = 0; - } - for (i = 0; i 32; i++) { - tmp = i ((i 3) * 8); - spi_vs_out_id[i / 4] |= tmp; + for (i = 0; i rshader-noutput; i++) { + if (rshader-output[i].spi_sid) { + tmp = rshader-output[i].spi_sid ((nparams 3) * 8); + spi_vs_out_id[nparams / 4] |= tmp; + nparams++; + } } + for (i = 0; i 10; i++) { r600_pipe_state_add_reg(rstate, R_02861C_SPI_VS_OUT_ID_0 + i * 4, @@ -2399,7 +2399,6 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader * VS is required to export at least one param and r600_shader_from_tgsi() * takes care of adding a dummy export. */ - nparams = rshader-noutput - rshader-npos; if (nparams 1) nparams = 1; diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 87164ce..448e03a 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -57,24 +57,6 @@ issued in the w slot as well. The compiler must issue the source argument to slots z, y, and x */ - -int r600_find_vs_semantic_index(struct r600_shader *vs, - struct r600_shader *ps, int id) -{ - struct r600_shader_io *input = ps-input[id]; - int index = 0; - - for (int i = 0; i vs-noutput; i++) { - if (input-name == vs-output[i].name - input-sid == vs-output[i].sid) - return index; - else if (vs-output[i].name != TGSI_SEMANTIC_POSITION - vs-output[i].name != TGSI_SEMANTIC_PSIZE) - index++; - } - return 0; -} - static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *shader) { struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; @@ -361,6 +343,44 @@ static int evergreen_interp_flat(struct r600_shader_ctx *ctx, int input) * DB_SOURCE_FORMAT - export control restrictions * */ + + +/* Map name/sid pair from tgsi to the 8-bit semantic index for SPI setup */ +static int r600_spi_sid(struct r600_shader_io * io) +{ + int index, name = io-name; + + /* These params are handled differently, they don't need + * semantic indices, so we'll use 0 for them. + */ + if (name == TGSI_SEMANTIC_POSITION || + name == TGSI_SEMANTIC_PSIZE || + name == TGSI_SEMANTIC_FACE) + index = 0; + else {
Re: [Mesa-dev] [PATCH 1/2] r600g: precalculate semantic indices for SPI setup
FYI, this commit completely breaks RV670. glxgears is completely black, other apps are either black or rendered incorrectly (mostly one-colored, the clear color I guess). Marek On Fri, Nov 4, 2011 at 6:24 PM, Vadim Girlin vadimgir...@gmail.com wrote: There is no need to duplicate semantic mapping which is done in hw, so get rid of r600_find_vs_semantic_index. TGSI name/sid pair is mapped to the 8-bit semantic index for SPI. Signed-off-by: Vadim Girlin vadimgir...@gmail.com --- This patch and the next one were tested on the evergreen, there are some changes in the test results: Following tests are passing due to slightly different handling of TGSI_SEMANTIC_BCOLOR (it's still not completely correct). vertex-program-two-side enabled back back2 fail - pass vertex-program-two-side enabled back front2 fail - pass vertex-program-two-side enabled front back2 fail - pass This test usually fails for me after these patches, but passes when it's run independently - probably unrelated: time-elapsed pass - fail src/gallium/drivers/r600/evergreen_state.c | 19 src/gallium/drivers/r600/r600_shader.c | 67 -- src/gallium/drivers/r600/r600_shader.h | 2 +- src/gallium/drivers/r600/r600_state.c | 20 +++- src/gallium/drivers/r600/r600_state_common.c | 13 ++--- 5 files changed, 64 insertions(+), 57 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index fd2e5da..904267d 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2375,20 +2375,20 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; struct r600_pipe_state *rstate = shader-rstate; struct r600_shader *rshader = shader-shader; - unsigned spi_vs_out_id[10]; - unsigned i, tmp, nparams; + unsigned spi_vs_out_id[10] = {}; + unsigned i, tmp, nparams = 0; /* clear previous register */ rstate-nregs = 0; - /* so far never got proper semantic id from tgsi */ - for (i = 0; i 10; i++) { - spi_vs_out_id[i] = 0; - } - for (i = 0; i 32; i++) { - tmp = i ((i 3) * 8); - spi_vs_out_id[i / 4] |= tmp; + for (i = 0; i rshader-noutput; i++) { + if (rshader-output[i].spi_sid) { + tmp = rshader-output[i].spi_sid ((nparams 3) * 8); + spi_vs_out_id[nparams / 4] |= tmp; + nparams++; + } } + for (i = 0; i 10; i++) { r600_pipe_state_add_reg(rstate, R_02861C_SPI_VS_OUT_ID_0 + i * 4, @@ -2399,7 +2399,6 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader * VS is required to export at least one param and r600_shader_from_tgsi() * takes care of adding a dummy export. */ - nparams = rshader-noutput - rshader-npos; if (nparams 1) nparams = 1; diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 87164ce..448e03a 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -57,24 +57,6 @@ issued in the w slot as well. The compiler must issue the source argument to slots z, y, and x */ - -int r600_find_vs_semantic_index(struct r600_shader *vs, - struct r600_shader *ps, int id) -{ - struct r600_shader_io *input = ps-input[id]; - int index = 0; - - for (int i = 0; i vs-noutput; i++) { - if (input-name == vs-output[i].name - input-sid == vs-output[i].sid) - return index; - else if (vs-output[i].name != TGSI_SEMANTIC_POSITION - vs-output[i].name != TGSI_SEMANTIC_PSIZE) - index++; - } - return 0; -} - static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *shader) { struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; @@ -361,6 +343,44 @@ static int evergreen_interp_flat(struct r600_shader_ctx *ctx, int input) * DB_SOURCE_FORMAT - export control restrictions * */ + + +/* Map name/sid pair from tgsi to the 8-bit semantic index for SPI setup */ +static int r600_spi_sid(struct r600_shader_io * io) +{ + int index, name = io-name; + + /* These params are handled differently, they don't need + * semantic indices, so we'll use 0 for them. + */ + if (name == TGSI_SEMANTIC_POSITION || + name == TGSI_SEMANTIC_PSIZE ||
Re: [Mesa-dev] [PATCH 1/2] r600g: precalculate semantic indices for SPI setup
On Fri, Nov 4, 2011 at 5:53 PM, Marek Olšák mar...@gmail.com wrote: FYI, this commit completely breaks RV670. glxgears is completely black, other apps are either black or rendered incorrectly (mostly one-colored, the clear color I guess). I knew I should have tested 6xx before I pushed. Reverted for now. Alex Marek On Fri, Nov 4, 2011 at 6:24 PM, Vadim Girlin vadimgir...@gmail.com wrote: There is no need to duplicate semantic mapping which is done in hw, so get rid of r600_find_vs_semantic_index. TGSI name/sid pair is mapped to the 8-bit semantic index for SPI. Signed-off-by: Vadim Girlin vadimgir...@gmail.com --- This patch and the next one were tested on the evergreen, there are some changes in the test results: Following tests are passing due to slightly different handling of TGSI_SEMANTIC_BCOLOR (it's still not completely correct). vertex-program-two-side enabled back back2 fail - pass vertex-program-two-side enabled back front2 fail - pass vertex-program-two-side enabled front back2 fail - pass This test usually fails for me after these patches, but passes when it's run independently - probably unrelated: time-elapsed pass - fail src/gallium/drivers/r600/evergreen_state.c | 19 src/gallium/drivers/r600/r600_shader.c | 67 -- src/gallium/drivers/r600/r600_shader.h | 2 +- src/gallium/drivers/r600/r600_state.c | 20 +++- src/gallium/drivers/r600/r600_state_common.c | 13 ++--- 5 files changed, 64 insertions(+), 57 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index fd2e5da..904267d 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2375,20 +2375,20 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; struct r600_pipe_state *rstate = shader-rstate; struct r600_shader *rshader = shader-shader; - unsigned spi_vs_out_id[10]; - unsigned i, tmp, nparams; + unsigned spi_vs_out_id[10] = {}; + unsigned i, tmp, nparams = 0; /* clear previous register */ rstate-nregs = 0; - /* so far never got proper semantic id from tgsi */ - for (i = 0; i 10; i++) { - spi_vs_out_id[i] = 0; - } - for (i = 0; i 32; i++) { - tmp = i ((i 3) * 8); - spi_vs_out_id[i / 4] |= tmp; + for (i = 0; i rshader-noutput; i++) { + if (rshader-output[i].spi_sid) { + tmp = rshader-output[i].spi_sid ((nparams 3) * 8); + spi_vs_out_id[nparams / 4] |= tmp; + nparams++; + } } + for (i = 0; i 10; i++) { r600_pipe_state_add_reg(rstate, R_02861C_SPI_VS_OUT_ID_0 + i * 4, @@ -2399,7 +2399,6 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader * VS is required to export at least one param and r600_shader_from_tgsi() * takes care of adding a dummy export. */ - nparams = rshader-noutput - rshader-npos; if (nparams 1) nparams = 1; diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 87164ce..448e03a 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -57,24 +57,6 @@ issued in the w slot as well. The compiler must issue the source argument to slots z, y, and x */ - -int r600_find_vs_semantic_index(struct r600_shader *vs, - struct r600_shader *ps, int id) -{ - struct r600_shader_io *input = ps-input[id]; - int index = 0; - - for (int i = 0; i vs-noutput; i++) { - if (input-name == vs-output[i].name - input-sid == vs-output[i].sid) - return index; - else if (vs-output[i].name != TGSI_SEMANTIC_POSITION - vs-output[i].name != TGSI_SEMANTIC_PSIZE) - index++; - } - return 0; -} - static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *shader) { struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; @@ -361,6 +343,44 @@ static int evergreen_interp_flat(struct r600_shader_ctx *ctx, int input) * DB_SOURCE_FORMAT - export control restrictions * */ + + +/* Map name/sid pair from tgsi to the 8-bit semantic index for SPI setup */ +static int r600_spi_sid(struct r600_shader_io * io) +{ + int index, name = io-name; + + /* These params are handled differently, they don't need + *