summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-09-28 15:27:46 -0700
committerJason Ekstrand <[email protected]>2017-10-12 22:39:29 -0700
commitfaad828b16448c1008a1b15ac8d8a72b13005c09 (patch)
tree61ba9e9f03390a20cc2255d648466247b4a4cbe0 /src/mesa
parent9b3f917f9ed177e6de6fc7231dc9a0ab75301dac (diff)
i965: Get rid of gen7_cs_state.c
The only thing it was handling was push constants. We pull the actual constant upload code into gen6_constant_state.c and the atoms into genX_state_upload.c. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/Makefile.sources1
-rw-r--r--src/mesa/drivers/dri/i965/brw_state.h5
-rw-r--r--src/mesa/drivers/dri/i965/gen6_constant_state.c74
-rw-r--r--src/mesa/drivers/dri/i965/gen7_cs_state.c173
-rw-r--r--src/mesa/drivers/dri/i965/genX_state_upload.c68
-rw-r--r--src/mesa/drivers/dri/i965/meson.build1
6 files changed, 145 insertions, 177 deletions
diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources
index a701b6a3579..053d89b81ec 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -68,7 +68,6 @@ i965_FILES = \
gen6_sampler_state.c \
gen6_sol.c \
gen6_urb.c \
- gen7_cs_state.c \
gen7_l3_state.c \
gen7_misc_state.c \
gen7_sol_state.c \
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index 97d03515599..42769b1deda 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -247,6 +247,11 @@ brw_upload_pull_constants(struct brw_context *brw,
const struct gl_program *prog,
struct brw_stage_state *stage_state,
const struct brw_stage_prog_data *prog_data);
+void
+brw_upload_cs_push_constants(struct brw_context *brw,
+ const struct gl_program *prog,
+ const struct brw_cs_prog_data *cs_prog_data,
+ struct brw_stage_state *stage_state);
/* gen7_vs_state.c */
void
diff --git a/src/mesa/drivers/dri/i965/gen6_constant_state.c b/src/mesa/drivers/dri/i965/gen6_constant_state.c
index a902c6849af..b2e357fd9d9 100644
--- a/src/mesa/drivers/dri/i965/gen6_constant_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_constant_state.c
@@ -201,3 +201,77 @@ brw_upload_pull_constants(struct brw_context *brw,
brw->ctx.NewDriverState |= brw_new_constbuf;
}
+
+/**
+ * Creates a region containing the push constants for the CS on gen7+.
+ *
+ * Push constants are constant values (such as GLSL uniforms) that are
+ * pre-loaded into a shader stage's register space at thread spawn time.
+ *
+ * For other stages, see brw_curbe.c:brw_upload_constant_buffer for the
+ * equivalent gen4/5 code and gen6_vs_state.c:gen6_upload_push_constants for
+ * gen6+.
+ */
+void
+brw_upload_cs_push_constants(struct brw_context *brw,
+ const struct gl_program *prog,
+ const struct brw_cs_prog_data *cs_prog_data,
+ struct brw_stage_state *stage_state)
+{
+ struct gl_context *ctx = &brw->ctx;
+ const struct brw_stage_prog_data *prog_data =
+ (struct brw_stage_prog_data*) cs_prog_data;
+
+ /* Updates the ParamaterValues[i] pointers for all parameters of the
+ * basic type of PROGRAM_STATE_VAR.
+ */
+ /* XXX: Should this happen somewhere before to get our state flag set? */
+ _mesa_load_state_parameters(ctx, prog->Parameters);
+
+ if (cs_prog_data->push.total.size == 0) {
+ stage_state->push_const_size = 0;
+ return;
+ }
+
+
+ gl_constant_value *param = (gl_constant_value*)
+ brw_state_batch(brw, ALIGN(cs_prog_data->push.total.size, 64),
+ 64, &stage_state->push_const_offset);
+ assert(param);
+
+ STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));
+
+ if (cs_prog_data->push.cross_thread.size > 0) {
+ gl_constant_value *param_copy = param;
+ assert(cs_prog_data->thread_local_id_index < 0 ||
+ cs_prog_data->thread_local_id_index >=
+ cs_prog_data->push.cross_thread.dwords);
+ for (unsigned i = 0;
+ i < cs_prog_data->push.cross_thread.dwords;
+ i++) {
+ param_copy[i] = *prog_data->param[i];
+ }
+ }
+
+ gl_constant_value thread_id;
+ if (cs_prog_data->push.per_thread.size > 0) {
+ for (unsigned t = 0; t < cs_prog_data->threads; t++) {
+ unsigned dst =
+ 8 * (cs_prog_data->push.per_thread.regs * t +
+ cs_prog_data->push.cross_thread.regs);
+ unsigned src = cs_prog_data->push.cross_thread.dwords;
+ for ( ; src < prog_data->nr_params; src++, dst++) {
+ if (src != cs_prog_data->thread_local_id_index)
+ param[dst] = *prog_data->param[src];
+ else {
+ thread_id.u = t * cs_prog_data->simd_size;
+ param[dst] = thread_id;
+ }
+ }
+ }
+ }
+
+ stage_state->push_const_size =
+ cs_prog_data->push.cross_thread.regs +
+ cs_prog_data->push.per_thread.regs;
+}
diff --git a/src/mesa/drivers/dri/i965/gen7_cs_state.c b/src/mesa/drivers/dri/i965/gen7_cs_state.c
deleted file mode 100644
index cdd6ad852cd..00000000000
--- a/src/mesa/drivers/dri/i965/gen7_cs_state.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright © 2015 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include "util/ralloc.h"
-#include "brw_context.h"
-#include "brw_defines.h"
-#include "brw_cs.h"
-#include "brw_wm.h"
-#include "intel_mipmap_tree.h"
-#include "intel_batchbuffer.h"
-#include "brw_state.h"
-#include "program/prog_statevars.h"
-#include "compiler/glsl/ir_uniform.h"
-#include "main/shaderapi.h"
-
-/**
- * Creates a region containing the push constants for the CS on gen7+.
- *
- * Push constants are constant values (such as GLSL uniforms) that are
- * pre-loaded into a shader stage's register space at thread spawn time.
- *
- * For other stages, see brw_curbe.c:brw_upload_constant_buffer for the
- * equivalent gen4/5 code and gen6_vs_state.c:gen6_upload_push_constants for
- * gen6+.
- */
-static void
-brw_upload_cs_push_constants(struct brw_context *brw,
- const struct gl_program *prog,
- const struct brw_cs_prog_data *cs_prog_data,
- struct brw_stage_state *stage_state)
-{
- struct gl_context *ctx = &brw->ctx;
- const struct brw_stage_prog_data *prog_data =
- (struct brw_stage_prog_data*) cs_prog_data;
-
- /* Updates the ParamaterValues[i] pointers for all parameters of the
- * basic type of PROGRAM_STATE_VAR.
- */
- /* XXX: Should this happen somewhere before to get our state flag set? */
- _mesa_load_state_parameters(ctx, prog->Parameters);
-
- if (cs_prog_data->push.total.size == 0) {
- stage_state->push_const_size = 0;
- return;
- }
-
-
- gl_constant_value *param = (gl_constant_value*)
- brw_state_batch(brw, ALIGN(cs_prog_data->push.total.size, 64),
- 64, &stage_state->push_const_offset);
- assert(param);
-
- STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));
-
- if (cs_prog_data->push.cross_thread.size > 0) {
- gl_constant_value *param_copy = param;
- assert(cs_prog_data->thread_local_id_index < 0 ||
- cs_prog_data->thread_local_id_index >=
- cs_prog_data->push.cross_thread.dwords);
- for (unsigned i = 0;
- i < cs_prog_data->push.cross_thread.dwords;
- i++) {
- param_copy[i] = *prog_data->param[i];
- }
- }
-
- gl_constant_value thread_id;
- if (cs_prog_data->push.per_thread.size > 0) {
- for (unsigned t = 0; t < cs_prog_data->threads; t++) {
- unsigned dst =
- 8 * (cs_prog_data->push.per_thread.regs * t +
- cs_prog_data->push.cross_thread.regs);
- unsigned src = cs_prog_data->push.cross_thread.dwords;
- for ( ; src < prog_data->nr_params; src++, dst++) {
- if (src != cs_prog_data->thread_local_id_index)
- param[dst] = *prog_data->param[src];
- else {
- thread_id.u = t * cs_prog_data->simd_size;
- param[dst] = thread_id;
- }
- }
- }
- }
-
- stage_state->push_const_size =
- cs_prog_data->push.cross_thread.regs +
- cs_prog_data->push.per_thread.regs;
-}
-
-
-static void
-gen7_upload_cs_push_constants(struct brw_context *brw)
-{
- struct brw_stage_state *stage_state = &brw->cs.base;
-
- /* BRW_NEW_COMPUTE_PROGRAM */
- const struct brw_program *cp =
- (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
-
- if (cp) {
- /* BRW_NEW_CS_PROG_DATA */
- struct brw_cs_prog_data *cs_prog_data =
- brw_cs_prog_data(brw->cs.base.prog_data);
-
- _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
- brw_upload_cs_push_constants(brw, &cp->program, cs_prog_data,
- stage_state);
- }
-}
-
-const struct brw_tracked_state gen7_cs_push_constants = {
- .dirty = {
- .mesa = _NEW_PROGRAM_CONSTANTS,
- .brw = BRW_NEW_BATCH |
- BRW_NEW_BLORP |
- BRW_NEW_COMPUTE_PROGRAM |
- BRW_NEW_CS_PROG_DATA,
- },
- .emit = gen7_upload_cs_push_constants,
-};
-
-/**
- * Creates a new CS constant buffer reflecting the current CS program's
- * constants, if needed by the CS program.
- */
-static void
-brw_upload_cs_pull_constants(struct brw_context *brw)
-{
- struct brw_stage_state *stage_state = &brw->cs.base;
-
- /* BRW_NEW_COMPUTE_PROGRAM */
- struct brw_program *cp =
- (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
-
- /* BRW_NEW_CS_PROG_DATA */
- const struct brw_stage_prog_data *prog_data = brw->cs.base.prog_data;
-
- _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
- /* _NEW_PROGRAM_CONSTANTS */
- brw_upload_pull_constants(brw, BRW_NEW_SURFACES, &cp->program,
- stage_state, prog_data);
-}
-
-const struct brw_tracked_state brw_cs_pull_constants = {
- .dirty = {
- .mesa = _NEW_PROGRAM_CONSTANTS,
- .brw = BRW_NEW_BATCH |
- BRW_NEW_BLORP |
- BRW_NEW_COMPUTE_PROGRAM |
- BRW_NEW_CS_PROG_DATA,
- },
- .emit = brw_upload_cs_pull_constants,
-};
diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index fd9eb17b9f2..2327a1bed19 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -4097,6 +4097,70 @@ static const struct brw_tracked_state genX(tcs_push_constants) = {
#if GEN_GEN >= 7
static void
+genX(upload_cs_push_constants)(struct brw_context *brw)
+{
+ struct brw_stage_state *stage_state = &brw->cs.base;
+
+ /* BRW_NEW_COMPUTE_PROGRAM */
+ const struct brw_program *cp =
+ (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
+
+ if (cp) {
+ /* BRW_NEW_CS_PROG_DATA */
+ struct brw_cs_prog_data *cs_prog_data =
+ brw_cs_prog_data(brw->cs.base.prog_data);
+
+ _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
+ brw_upload_cs_push_constants(brw, &cp->program, cs_prog_data,
+ stage_state);
+ }
+}
+
+const struct brw_tracked_state genX(cs_push_constants) = {
+ .dirty = {
+ .mesa = _NEW_PROGRAM_CONSTANTS,
+ .brw = BRW_NEW_BATCH |
+ BRW_NEW_BLORP |
+ BRW_NEW_COMPUTE_PROGRAM |
+ BRW_NEW_CS_PROG_DATA,
+ },
+ .emit = genX(upload_cs_push_constants),
+};
+
+/**
+ * Creates a new CS constant buffer reflecting the current CS program's
+ * constants, if needed by the CS program.
+ */
+static void
+genX(upload_cs_pull_constants)(struct brw_context *brw)
+{
+ struct brw_stage_state *stage_state = &brw->cs.base;
+
+ /* BRW_NEW_COMPUTE_PROGRAM */
+ struct brw_program *cp =
+ (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
+
+ /* BRW_NEW_CS_PROG_DATA */
+ const struct brw_stage_prog_data *prog_data = brw->cs.base.prog_data;
+
+ _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
+ /* _NEW_PROGRAM_CONSTANTS */
+ brw_upload_pull_constants(brw, BRW_NEW_SURFACES, &cp->program,
+ stage_state, prog_data);
+}
+
+const struct brw_tracked_state genX(cs_pull_constants) = {
+ .dirty = {
+ .mesa = _NEW_PROGRAM_CONSTANTS,
+ .brw = BRW_NEW_BATCH |
+ BRW_NEW_BLORP |
+ BRW_NEW_COMPUTE_PROGRAM |
+ BRW_NEW_CS_PROG_DATA,
+ },
+ .emit = genX(upload_cs_pull_constants),
+};
+
+static void
genX(upload_cs_state)(struct brw_context *brw)
{
if (!brw->cs.base.prog_data)
@@ -5597,8 +5661,8 @@ genX(init_atoms)(struct brw_context *brw)
{
&gen7_l3_state,
&brw_cs_image_surfaces,
- &gen7_cs_push_constants,
- &brw_cs_pull_constants,
+ &genX(cs_push_constants),
+ &genX(cs_pull_constants),
&brw_cs_ubo_surfaces,
&brw_cs_abo_surfaces,
&brw_cs_texture_surfaces,
diff --git a/src/mesa/drivers/dri/i965/meson.build b/src/mesa/drivers/dri/i965/meson.build
index 0fbad4181a2..144a254bd64 100644
--- a/src/mesa/drivers/dri/i965/meson.build
+++ b/src/mesa/drivers/dri/i965/meson.build
@@ -88,7 +88,6 @@ files_i965 = files(
'gen6_sampler_state.c',
'gen6_sol.c',
'gen6_urb.c',
- 'gen7_cs_state.c',
'gen7_l3_state.c',
'gen7_misc_state.c',
'gen7_sol_state.c',