r600g: Set geometry properties in r600_create_shader_state()
authorEdward O'Callaghan <eocallaghan@alterapraxis.com>
Sat, 29 Aug 2015 08:31:08 +0000 (18:31 +1000)
committerMarek Olšák <marek.olsak@amd.com>
Sun, 30 Aug 2015 09:41:00 +0000 (11:41 +0200)
The selector is shared by all shader variants, so the
individual shaders shouldn't change it. Use tgsi_shader_scan()
results to set geometry properties within a
r600_create_shader_state() call and treat said propertices in
the selector as read-only within r600_shader_from_tgsi().

Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r600_state_common.c

index eb7036048e54b268a56f94809f7d52af5818c8a3..4bd3d7cf75b300fd985390575c7be375a0b0d40f 100644 (file)
@@ -36,6 +36,8 @@
 #include "util/list.h"
 #include "util/u_transfer.h"
 
+#include "tgsi/tgsi_scan.h"
+
 #define R600_NUM_ATOMS 75
 
 #define R600_MAX_VIEWPORTS 16
@@ -305,6 +307,7 @@ struct r600_pipe_shader_selector {
 
        struct tgsi_token       *tokens;
        struct pipe_stream_output_info  so;
+       struct tgsi_shader_info         info;
 
        unsigned        num_shaders;
 
index f0b794c809e013578019feef9e6f87ddafe0cb78..a265fb8122533f45f6ae47d95377f60bbe1a9d7e 100644 (file)
@@ -1809,7 +1809,6 @@ static int r600_shader_from_tgsi(struct r600_context *rctx,
        struct tgsi_token *tokens = pipeshader->selector->tokens;
        struct pipe_stream_output_info so = pipeshader->selector->so;
        struct tgsi_full_immediate *immediate;
-       struct tgsi_full_property *property;
        struct r600_shader_ctx ctx;
        struct r600_bytecode_output output[32];
        unsigned output_done, noutput;
@@ -1968,6 +1967,12 @@ static int r600_shader_from_tgsi(struct r600_context *rctx,
        ctx.nliterals = 0;
        ctx.literals = NULL;
        shader->fs_write_all = FALSE;
+       if (ctx.info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS])
+               shader->fs_write_all = TRUE;
+
+       shader->vs_position_window_space = FALSE;
+       if (ctx.info.properties[TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION])
+               shader->vs_position_window_space = TRUE;
 
        if (shader->vs_as_gs_a)
                vs_add_primid_output(&ctx, key.vs.prim_id_out);
@@ -1994,31 +1999,7 @@ static int r600_shader_from_tgsi(struct r600_context *rctx,
                                goto out_err;
                        break;
                case TGSI_TOKEN_TYPE_INSTRUCTION:
-                       break;
                case TGSI_TOKEN_TYPE_PROPERTY:
-                       property = &ctx.parse.FullToken.FullProperty;
-                       switch (property->Property.PropertyName) {
-                       case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS:
-                               if (property->u[0].Data == 1)
-                                       shader->fs_write_all = TRUE;
-                               break;
-                       case TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION:
-                               if (property->u[0].Data == 1)
-                                       shader->vs_position_window_space = TRUE;
-                               break;
-                       case TGSI_PROPERTY_VS_PROHIBIT_UCPS:
-                               /* we don't need this one */
-                               break;
-                       case TGSI_PROPERTY_GS_OUTPUT_PRIM:
-                               pipeshader->selector->gs_output_prim = property->u[0].Data;
-                               break;
-                       case TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES:
-                               pipeshader->selector->gs_max_out_vertices = property->u[0].Data;
-                               break;
-                       case TGSI_PROPERTY_GS_INVOCATIONS:
-                               pipeshader->selector->gs_num_invocations = property->u[0].Data;
-                               break;
-                       }
                        break;
                default:
                        R600_ERR("unsupported token type %d\n", ctx.parse.FullToken.Token.Type);
index 63746b555026fee39f9fc8bd38380e1cf7cc4b78..d9cf736b0438916891ab65d21daea52a6e6be8b4 100644 (file)
@@ -34,6 +34,7 @@
 #include "util/u_upload_mgr.h"
 #include "util/u_math.h"
 #include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_scan.h"
 
 void r600_init_command_buffer(struct r600_command_buffer *cb, unsigned num_dw)
 {
@@ -818,6 +819,19 @@ static void *r600_create_shader_state(struct pipe_context *ctx,
        sel->type = pipe_shader_type;
        sel->tokens = tgsi_dup_tokens(state->tokens);
        sel->so = state->stream_output;
+       tgsi_scan_shader(state->tokens, &sel->info);
+
+       switch (pipe_shader_type) {
+       case PIPE_SHADER_GEOMETRY:
+               sel->gs_output_prim =
+                       sel->info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM];
+               sel->gs_max_out_vertices =
+                       sel->info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES];
+               sel->gs_num_invocations =
+                       sel->info.properties[TGSI_PROPERTY_GS_INVOCATIONS];
+               break;
+       }
+
        return sel;
 }