summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdiel Janulgue <abdiel.janulgue@linux.intel.com>2015-04-24 12:27:32 +0300
committerAbdiel Janulgue <abdiel.janulgue@linux.intel.com>2015-04-28 22:22:45 +0300
commitbd430af18e4185862ba54bb92b0c5c3e89793dc5 (patch)
treed661537245c408b07a9703945d3f1d05d56f2eb7
parent3c0b0e1776ed1744a4c35513e457b14ee056ac6b (diff)
i965: Include UBO parameter sizes in push constant parameters
Now that we consider UBO constants as push constants, we need to include the sizes of the UBO's constant slots in the visitor's uniform slot sizes. This information is needed to properly pack vector constants tightly next to each other. Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs.c11
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs.c13
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.c13
3 files changed, 37 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index 97658d59f0..2dc3ea1cb1 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -32,6 +32,7 @@
#include "brw_vec4_gs_visitor.h"
#include "brw_state.h"
#include "brw_ff_gs.h"
+#include "glsl/nir/nir_types.h"
bool
@@ -70,6 +71,16 @@ brw_compile_gs_prog(struct brw_context *brw,
c.prog_data.base.base.pull_param =
rzalloc_array(NULL, const gl_constant_value *, param_count);
c.prog_data.base.base.nr_params = param_count;
+ c.prog_data.base.base.nr_ubo_params = 0;
+ for (int i = 0; i < gs->NumUniformBlocks; i++) {
+ for (int p = 0; p < gs->UniformBlocks[i].NumUniforms; p++) {
+ const struct glsl_type *type = gs->UniformBlocks[i].Uniforms[p].Type;
+ const struct glsl_type *elem = glsl_get_element_type(type);
+ int array_sz = elem ? glsl_get_array_size(type) : 1;
+ int components = elem ? glsl_get_components(elem) : glsl_get_components(type);
+ c.prog_data.base.base.nr_ubo_params += components * array_sz;
+ }
+ }
c.prog_data.base.base.nr_gather_table = 0;
c.prog_data.base.base.gather_table =
rzalloc_size(NULL, sizeof(*c.prog_data.base.base.gather_table) *
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 52333c9104..86bef5e460 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -37,6 +37,7 @@
#include "brw_state.h"
#include "program/prog_print.h"
#include "program/prog_parameter.h"
+#include "glsl/nir/nir_types.h"
#include "util/ralloc.h"
@@ -243,6 +244,18 @@ brw_compile_vs_prog(struct brw_context *brw,
rzalloc_array(NULL, const gl_constant_value *, param_count);
stage_prog_data->nr_params = param_count;
+ stage_prog_data->nr_ubo_params = 0;
+ if (vs) {
+ for (int i = 0; i < vs->NumUniformBlocks; i++) {
+ for (int p = 0; p < vs->UniformBlocks[i].NumUniforms; p++) {
+ const struct glsl_type *type = vs->UniformBlocks[i].Uniforms[p].Type;
+ const struct glsl_type *elem = glsl_get_element_type(type);
+ int array_sz = elem ? glsl_get_array_size(type) : 1;
+ int components = elem ? glsl_get_components(elem) : glsl_get_components(type);
+ stage_prog_data->nr_ubo_params += components * array_sz;
+ }
+ }
+ }
stage_prog_data->nr_gather_table = 0;
stage_prog_data->gather_table = rzalloc_size(NULL, sizeof(*stage_prog_data->gather_table) *
(stage_prog_data->nr_params +
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 13a64d89a8..2060eab024 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -38,6 +38,7 @@
#include "main/samplerobj.h"
#include "program/prog_parameter.h"
#include "program/program.h"
+#include "glsl/nir/nir_types.h"
#include "intel_mipmap_tree.h"
#include "util/ralloc.h"
@@ -205,6 +206,18 @@ brw_compile_wm_prog(struct brw_context *brw,
rzalloc_array(NULL, const gl_constant_value *, param_count);
prog_data.base.nr_params = param_count;
+ prog_data.base.nr_ubo_params = 0;
+ if (fs) {
+ for (int i = 0; i < fs->NumUniformBlocks; i++) {
+ for (int p = 0; p < fs->UniformBlocks[i].NumUniforms; p++) {
+ const struct glsl_type *type = fs->UniformBlocks[i].Uniforms[p].Type;
+ const struct glsl_type *elem = glsl_get_element_type(type);
+ int array_sz = elem ? glsl_get_array_size(type) : 1;
+ int components = elem ? glsl_get_components(elem) : glsl_get_components(type);
+ prog_data.base.nr_ubo_params += components * array_sz;
+ }
+ }
+ }
prog_data.base.nr_gather_table = 0;
prog_data.base.gather_table = rzalloc_size(NULL, sizeof(*prog_data.base.gather_table) *
(prog_data.base.nr_params +