Commit Graph

32 Commits

Author SHA1 Message Date
Timothy Arceri da28280544 mesa: pass ctx to add_uniform_to_shader constructor
Fixes: 4c2422067b ("glsl: pass UseSTD430AsDefaultPacking to where it will be used")

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2017-08-22 21:25:55 +10:00
Nicolai Hähnle e749995326 st/mesa: replace st_shader_stage_to_ptarget
Use pipe_shader_type_from_mesa instead.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-08-02 14:18:52 +02:00
Nicolai Hähnle e044e9eb2a st/glsl_to_nir: move nir_lower_io to drivers
This allows drivers more freedom in how exactly they want to lower I/O,
e.g. first lowering I/O to temporaries.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-07-31 14:55:30 +02:00
Nicolai Hähnle c5f97eab09 st/mesa: get rid of st_glsl_types
It's a duplicate of glsl_type::count_attribute_slots.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-07-31 14:55:30 +02:00
Nicolai Hähnle 2cf8c84619 st/glsl_to_nir: use nir_lower_samplers_as_deref when requested by the driver
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-07-31 14:55:29 +02:00
Nicolai Hähnle 06d038c4bd st/glsl_to_nir: fix the case where NIR clone testing is enabled
In that case, prog->nir must be assigned at the end.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-07-31 14:55:29 +02:00
Nicolai Hähnle c2065ed687 st/glsl_to_nir: fix edgeflag passthrough
We have to mark the additional shader input as used, otherwise it will
be eliminated, and we have to setup its index correctly.

This is a bit of a hack, but so is everything surrounding edgeflag
passthrough.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-07-05 12:27:12 +02:00
Samuel Pitoiset 878a6e6eed mesa: pass gl_program to _mesa_associate_uniform_storage()
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-06-14 10:04:36 +02:00
Rob Clark 5f7e55582e mesa/st: compute support for glsl_to_nir
Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-05-04 13:48:06 -04:00
Vinson Lee f30f575e7b st/mesa: Fix missing-braces warning.
CXX      state_tracker/st_glsl_to_nir.lo
state_tracker/st_glsl_to_nir.cpp:250:57: warning: suggest braces around initialization of subobject [-Wmissing-braces]
      nir_lower_wpos_ytransform_options wpos_options = {0};
                                                        ^
                                                        {}

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2017-04-12 15:43:30 -07:00
Brian Paul ee3f75f538 st/mesa: silence unused/uninitialized var warnings
Signed-off-by: Brian Paul <brianp@vmware.com>
2017-04-07 13:46:44 -06:00
Timothy Arceri 20234cfe3a st/mesa: don't propagate uniforms when restoring from cache
We will have already loaded the uniforms when the parameter list
was restored from cache.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-08 09:45:48 +11:00
Timothy Arceri 076ab157ff st/mesa/glsl: move SamplerTargets to gl_program
This will help allow us to simplify the handling of samplers by
storing them in a single location rather than duplicating them in
both gl_linked_shader and gl_program.

Reviewed-by: Eric Anholt <eric@anholt.net>
2017-01-06 11:21:42 +11:00
Timothy Arceri 937523971f st/mesa/glsl: set SamplersUsed directly in gl_program
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-01-06 11:21:42 +11:00
Timothy Arceri 9d96d3803a glsl: create gl_program at the start of linking rather than the end
This will allow us to directly store metadata we want to retain in
gl_program this metadata is currently stored in gl_linked_shader and
will be lost if relinking fails even though the program will remain
in use and is still valid according to the spec.

"If a program object that is active for any shader stage is re-linked
unsuccessfully, the link status will be set to FALSE, but any existing
executables and associated state will remain part of the current
rendering state until a subsequent call to UseProgram,
UseProgramStages, or BindProgramPipeline removes them from use."

This change will also help avoid the double handing that happens in
_mesa_copy_linked_program_data().

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-19 07:42:33 +11:00
Timothy Arceri 2b8f97d0ff st/mesa/i965: simplify gl_program references and stop leaking
In i965 we were calling _mesa_reference_program() after creating
gl_program and then later calling it again with NULL as a param
to get the refcount back down to 1. This changes things to not
use _mesa_reference_program() at all and just have gl_linked_shader
take ownership of gl_program since refcount starts at 1.

The st and ir_to_mesa linkers were worse as they were both getting
in a state were the refcount would never get to 0 and we would leak
the program.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-19 07:42:33 +11:00
Timothy Arceri d6bdb3a862 st/mesa: stop initialing Instructions and NumInstructions
Since gl_program is now created with rzalloc() they should
already be initialised.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-17 12:52:59 +11:00
Timothy Arceri 2e423ca147 nir: stop adjusting driver location for varying packing
As of 59864e8e02 we just use the location assigned by the front-end and
no longer need this for i965.

Since there were some issues in the logic with assigning arrays the same
driver location if they didn't start at the same location just remove it
and let other drivers implement a solution if needed when they add
ARB_enhanced_layouts support.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-10-26 14:29:36 +11:00
Timothy Arceri 24093975e8 st/mesa: use common double inputs read field
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-10-26 14:29:36 +11:00
Timothy Arceri e81aaeba37 r200/i915/st/mesa/compiler: use common inputs read field
And set set inputs_read directly in shader_info.

To avoid regressions between changes this change is a squashed
version of the following patches.

st/mesa changes where:
Reviewed-by: Marek Olšák <marek.olsak@amd.com>

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-10-26 14:29:36 +11:00
Timothy Arceri 9d2b391165 glsl: add temporary copy_shader_info() function
This function is added here to ease refactoring towards using the new shared
shader_info. Once refactoring is complete and values are set directly it
will be removed.

We call it from _mesa_copy_linked_program_data() rather than glsl_to_nir()
so that the values will be set for all drivers. In order to do this some
calls need to be moved around so that we make sure to call
do_set_program_inouts() before _mesa_copy_linked_program_data()

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-10-26 14:29:36 +11:00
Timothy Arceri e40d32b3ec mesa: modify _mesa_copy_linked_program_data() to take gl_linked_shader
This allows us to do some small tidy ups, but will also allow us to call
a new function that copies values to a shared shader info from here.

In order to make this change this function now requires
_mesa_reference_program() to have previously been called.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-10-26 14:29:36 +11:00
Rob Clark ecd6fce261 mesa/st: support lowering multi-planar YUV
Support multi-planar YUV for external EGLImage's (currently just in the
dma-buf import path) by lowering to multiple texture fetch's for each
plane and CSC in shader.

There was some discussion of alternative approaches for tracking the
additional UV or U/V planes:

  https://lists.freedesktop.org/archives/mesa-dev/2016-September/127832.html

They all seemed worse than pipe_resource::next

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-09-26 15:29:17 -04:00
Jason Ekstrand ed65e6ef49 nir: Add a flag to lower_io to force "sample" interpolation
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-09-15 13:31:43 -07:00
Thomas Helland 08c5b10ae9 mesa/glsl: Move string_to_uint_map into the util folder
This clears the last bits of the usecases of the hash table
located in mesa/program, allowing us to remove it.

V2: Rebase on top of changes to Makefile.sources

Signed-off-by: Thomas Helland <thomashelland90@gmail.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
2016-09-12 10:48:35 +10:00
Kai Wasserbäch 532db3b788 gallium: Use enum pipe_shader_type in set_sampler_views()
Signed-off-by: Kai Wasserbäch <kai@dev.carbon-project.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
2016-08-29 09:07:25 -06:00
Eric Anholt d08f09c24e st/nir: Trim out unused VS input variables.
If we're going to skip setting up vertex input data in them, we should
probably not leave them as vertex inputs with a driver_location that
happens to alias to something else.

Fixes a regression in glsl-mat-attribute on vc4 when enabling GTN.

v2: Change commit message shortlog, lower the new globals away before
    handing off to the driver.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-08-22 12:11:05 -07:00
Timothy Arceri 448adfbc67 nir: use the same driver location for packed varyings
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-07-07 10:26:43 +10:00
Timothy Arceri 1fb8c6df88 glsl/mesa: split gl_shader in two
There are two distinctly different uses of this struct. The first
is to store GL shader objects. The second is to store information
about a shader stage thats been linked.

The two uses actually share few fields and there is clearly confusion
about their use. For example the linked shaders map one to one with
a program so can simply be destroyed along with the program. However
previously we were calling reference counting on the linked shaders.

We were also creating linked shaders with a name even though it
is always 0 and called the driver version of the _mesa_new_shader()
function unnecessarily for GL shader objects.

Acked-by: Iago Toral Quiroga <itoral@igalia.com>
2016-06-30 16:51:25 +10:00
Timothy Arceri 31dee99e05 mesa/glsl: stop using GL shader type internally
Instead use the internal gl_shader_stage enum everywhere. This
makes things more consistent and gets rid of unnecessary
conversions.

Ideally it would be nice to remove the Type field from gl_shader
altogether but currently it is used to differentiate between
gl_shader and gl_shader_program in the ShaderObjects hash table.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-06-16 10:45:35 +10:00
Jason Ekstrand 32210dea8e compiler: Move glsl_to_nir to libglsl.la
Right now libglsl.la depends on libnir.la so putting it in libnir.la
adds a dependency on libglsl.la that goes the wrong direction.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2016-05-26 14:13:38 -07:00
Rob Clark 1e93b0caa1 mesa/st: add support for NIR as possible driver IR
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Acked-by: Eric Anholt <eric@anholt.net>
2016-05-17 14:22:46 -04:00