On Mon, Oct 26, 2015 at 11:06 AM, Rob Clark <robdcl...@gmail.com> wrote: > On Mon, Oct 26, 2015 at 1:52 PM, Jason Ekstrand <ja...@jlekstrand.net> wrote: >> On Sat, Oct 24, 2015 at 10:07 AM, Rob Clark <robdcl...@gmail.com> wrote: >>> From: Rob Clark <robcl...@freedesktop.org> >>> >>> This will simplify things somewhat in clone. >>> >>> Signed-off-by: Rob Clark <robcl...@freedesktop.org> >>> --- >>> src/glsl/nir/glsl_to_nir.cpp | 6 ++++++ >>> src/glsl/nir/nir.h | 11 +++++++++++ >>> 2 files changed, 17 insertions(+) >>> >>> diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp >>> index 9b50a93..8f83012 100644 >>> --- a/src/glsl/nir/glsl_to_nir.cpp >>> +++ b/src/glsl/nir/glsl_to_nir.cpp >>> @@ -238,6 +238,8 @@ constant_copy(ir_constant *ir, void *mem_ctx) >>> >>> unsigned total_elems = ir->type->components(); >>> unsigned i; >>> + >>> + ret->num_elements = 0; >>> switch (ir->type->base_type) { >>> case GLSL_TYPE_UINT: >>> for (i = 0; i < total_elems; i++) >>> @@ -262,6 +264,8 @@ constant_copy(ir_constant *ir, void *mem_ctx) >>> case GLSL_TYPE_STRUCT: >>> ret->elements = ralloc_array(mem_ctx, nir_constant *, >>> ir->type->length); >>> + ret->num_elements = ir->type->length; >>> + >>> i = 0; >>> foreach_in_list(ir_constant, field, &ir->components) { >>> ret->elements[i] = constant_copy(field, mem_ctx); >>> @@ -272,6 +276,7 @@ constant_copy(ir_constant *ir, void *mem_ctx) >>> case GLSL_TYPE_ARRAY: >>> ret->elements = ralloc_array(mem_ctx, nir_constant *, >>> ir->type->length); >>> + ret->num_elements = ir->type->length; >>> >>> for (i = 0; i < ir->type->length; i++) >>> ret->elements[i] = constant_copy(ir->array_elements[i], mem_ctx); >>> @@ -293,6 +298,7 @@ nir_visitor::visit(ir_variable *ir) >>> >>> if (ir->is_interface_instance() && ir->get_max_ifc_array_access() != >>> NULL) { >>> unsigned size = ir->get_interface_type()->length; >>> + var->num_max_ifc_array_access = size; >>> var->max_ifc_array_access = ralloc_array(var, unsigned, size); >>> memcpy(var->max_ifc_array_access, ir->get_max_ifc_array_access(), >>> size * sizeof(unsigned)); >>> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h >>> index a09c2a6..2d9c94c 100644 >>> --- a/src/glsl/nir/nir.h >>> +++ b/src/glsl/nir/nir.h >>> @@ -112,6 +112,11 @@ typedef struct nir_constant { >>> */ >>> union nir_constant_data value; >>> >>> + /* we could get this from the var->type but makes clone *much* easier to >>> + * not have to care about the type. >>> + */ >>> + unsigned num_elements; >>> + >>> /* Array elements / Structure Fields */ >>> struct nir_constant **elements; >>> } nir_constant; >>> @@ -148,6 +153,12 @@ typedef struct { >>> */ >>> char *name; >>> >>> + /* we could figure this out from interface_type but it isn't exposed >>> + * cleanly outside of c++ and just having the length here simplifies >>> + * clone: >>> + */ >>> + unsigned num_max_ifc_array_access; >> >> Can we just get rid of max_ifc_array_access instead? It's something >> that GLSL uses for some optimizations somewhere but NIR has never made >> any use of it whatsoever and none of the backends care. The only >> reason it's here is because Connor copied and pasted ir_variable into >> NIR variable. > > I only kept it because I assumed at some point someone would want it > (ie. porting opt's done in IR over to NIR, etc). But no problem for > me to drop it.
That's a really bad reason to keep dead code... We'll add something back in if/when we need it. > BR, > -R > >> --Jason >> >>> + >>> /** >>> * For variables which satisfy the is_interface_instance() predicate, >>> this >>> * points to an array of integers such that if the ith member of the >>> -- >>> 2.5.0 >>> _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev