mesa.git
9 years agonir/types: Add support for sampler types
Jason Ekstrand [Sat, 16 May 2015 19:32:58 +0000 (12:32 -0700)]
nir/types: Add support for sampler types

9 years agonir/spirv: Make the global constants in spirv.h static
Jason Ekstrand [Wed, 6 May 2015 22:36:54 +0000 (15:36 -0700)]
nir/spirv: Make the global constants in spirv.h static

I've been promissed in a bug that this will be fixed in a future version of
the header.  However, in the interest of my branch building, I'm adding
these changes in myself for the moment.

9 years agonir/spirv: Handle jump-to-loop in a more general way
Jason Ekstrand [Wed, 6 May 2015 22:33:21 +0000 (15:33 -0700)]
nir/spirv: Handle jump-to-loop in a more general way

9 years agonir/spirv: Handle boolean uniforms correctly
Jason Ekstrand [Wed, 6 May 2015 19:54:02 +0000 (12:54 -0700)]
nir/spirv: Handle boolean uniforms correctly

9 years agonir/spirv: Handle control-flow with loops
Jason Ekstrand [Wed, 6 May 2015 19:37:10 +0000 (12:37 -0700)]
nir/spirv: Handle control-flow with loops

9 years agonir/spirv: Set a name on temporary variables
Jason Ekstrand [Wed, 6 May 2015 19:36:31 +0000 (12:36 -0700)]
nir/spirv: Set a name on temporary variables

9 years agonir/spirv: Use the correct length for copying string literals
Jason Ekstrand [Wed, 6 May 2015 19:36:09 +0000 (12:36 -0700)]
nir/spirv: Use the correct length for copying string literals

9 years agonir/spirv: Make vtn_ssa_value handle constants as well as ssa values
Jason Ekstrand [Wed, 6 May 2015 19:35:30 +0000 (12:35 -0700)]
nir/spirv: Make vtn_ssa_value handle constants as well as ssa values

9 years agonir/spirv: Add initial support for GLSL 4.50 builtins
Jason Ekstrand [Mon, 4 May 2015 22:17:56 +0000 (15:17 -0700)]
nir/spirv: Add initial support for GLSL 4.50 builtins

9 years agonir/spirv: Split the core datastructures into a header file
Jason Ekstrand [Mon, 4 May 2015 19:25:09 +0000 (12:25 -0700)]
nir/spirv: Split the core datastructures into a header file

9 years agonir/spirv: Use the builder for all instructions
Jason Ekstrand [Mon, 4 May 2015 19:12:23 +0000 (12:12 -0700)]
nir/spirv: Use the builder for all instructions

We don't actually use it to create all the instructions but we do use it
for insertion always.  This should make things far more consistent for
implementing extended instructions.

9 years agonir/spirv: Add support for a bunch of ALU operations
Jason Ekstrand [Mon, 4 May 2015 19:04:02 +0000 (12:04 -0700)]
nir/spirv: Add support for a bunch of ALU operations

9 years agonir/spirv: Add support for indirect array accesses
Jason Ekstrand [Mon, 4 May 2015 19:02:57 +0000 (12:02 -0700)]
nir/spirv: Add support for indirect array accesses

9 years agonir/spirv: Explicitly type constants and SSA values
Jason Ekstrand [Mon, 4 May 2015 19:02:24 +0000 (12:02 -0700)]
nir/spirv: Explicitly type constants and SSA values

9 years agonir/spirv: Handle OpBranchConditional
Jason Ekstrand [Mon, 4 May 2015 17:23:09 +0000 (10:23 -0700)]
nir/spirv: Handle OpBranchConditional

We do control-flow handling as a two-step process.  The first step is to
walk the instructions list and record various information about blocks and
functions.  This is where the acutal nir_function_overload objects get
created.  We also record the start/stop instruction for each block.  Then
a second pass walks over each of the functions and over the blocks in each
function in a way that's NIR-friendly and actually parses the instructions.

9 years agonir/spirv: Add a helper for getting a value as an SSA value
Jason Ekstrand [Mon, 4 May 2015 17:22:52 +0000 (10:22 -0700)]
nir/spirv: Add a helper for getting a value as an SSA value

9 years agonir/spirv: Split instruction handling into preamble and body sections
Jason Ekstrand [Fri, 1 May 2015 21:00:57 +0000 (14:00 -0700)]
nir/spirv: Split instruction handling into preamble and body sections

9 years agonir/spirv: Implement load/store instructiosn
Jason Ekstrand [Fri, 1 May 2015 18:28:18 +0000 (11:28 -0700)]
nir/spirv: Implement load/store instructiosn

9 years agonir: Add a helper for getting the tail of a deref chain
Jason Ekstrand [Mon, 4 May 2015 17:19:24 +0000 (10:19 -0700)]
nir: Add a helper for getting the tail of a deref chain

9 years agonir/spirv: Actaully add variables to the funciton or shader
Jason Ekstrand [Fri, 1 May 2015 18:28:01 +0000 (11:28 -0700)]
nir/spirv: Actaully add variables to the funciton or shader

9 years agonir/spirv: Add a vtn_untyped_value helper
Jason Ekstrand [Fri, 1 May 2015 18:27:44 +0000 (11:27 -0700)]
nir/spirv: Add a vtn_untyped_value helper

9 years agonir/spirv: Use vtn_value in the types code and fix a off-by-one error
Jason Ekstrand [Fri, 1 May 2015 18:27:21 +0000 (11:27 -0700)]
nir/spirv: Use vtn_value in the types code and fix a off-by-one error

9 years agonir/types: Add an is_vector_or_scalar helper
Jason Ekstrand [Fri, 1 May 2015 18:26:40 +0000 (11:26 -0700)]
nir/types: Add an is_vector_or_scalar helper

9 years agonir/spirv: Add support for deref chains
Jason Ekstrand [Thu, 30 Apr 2015 03:56:36 +0000 (20:56 -0700)]
nir/spirv: Add support for deref chains

9 years agonir/types: Add a scalar type constructor
Jason Ekstrand [Thu, 30 Apr 2015 03:56:17 +0000 (20:56 -0700)]
nir/types: Add a scalar type constructor

9 years agonir/spirv: Add support for OpLabel
Jason Ekstrand [Thu, 30 Apr 2015 03:19:34 +0000 (20:19 -0700)]
nir/spirv: Add support for OpLabel

9 years agonir/spirv: Add support for declaring functions
Jason Ekstrand [Thu, 30 Apr 2015 03:10:20 +0000 (20:10 -0700)]
nir/spirv: Add support for declaring functions

9 years agonir/types: Add accessors for function parameter/return types
Jason Ekstrand [Thu, 30 Apr 2015 03:09:36 +0000 (20:09 -0700)]
nir/types: Add accessors for function parameter/return types

9 years agonir/spirv: Add support for declaring variables
Jason Ekstrand [Thu, 30 Apr 2015 02:37:41 +0000 (19:37 -0700)]
nir/spirv: Add support for declaring variables

Deref chains and variable load/store operations are still missing.

9 years agonir/spirv: Add support for constants
Jason Ekstrand [Thu, 30 Apr 2015 01:14:11 +0000 (18:14 -0700)]
nir/spirv: Add support for constants

9 years agonir/spirv: Add basic support for types
Jason Ekstrand [Wed, 29 Apr 2015 21:36:01 +0000 (14:36 -0700)]
nir/spirv: Add basic support for types

9 years agonir/types: Add more helpers for creating types
Jason Ekstrand [Wed, 29 Apr 2015 21:28:37 +0000 (14:28 -0700)]
nir/types: Add more helpers for creating types

9 years agoglsl/types: Expose the function_param and struct_field structs to C
Jason Ekstrand [Wed, 29 Apr 2015 21:48:12 +0000 (14:48 -0700)]
glsl/types: Expose the function_param and struct_field structs to C

Previously, they were hidden behind a #ifdef __cplusplus so C wouldn't find
them.  This commit simpliy moves the ifdef.

9 years agoglsl/types: Add support for function types
Jason Ekstrand [Wed, 25 Feb 2015 00:29:33 +0000 (16:29 -0800)]
glsl/types: Add support for function types

9 years agoglsl: Add GLSL_TYPE_FUNCTION to the base types enums
Jason Ekstrand [Wed, 25 Feb 2015 00:27:32 +0000 (16:27 -0800)]
glsl: Add GLSL_TYPE_FUNCTION to the base types enums

9 years agonir/spirv: Rework the way values are added
Jason Ekstrand [Wed, 29 Apr 2015 21:34:06 +0000 (14:34 -0700)]
nir/spirv: Rework the way values are added

Instead of having functions to add values and set various things, we just
have a function that does a few asserts and then returns the value.  The
caller is then responsible for setting the various fields.

9 years agonir/spirv: Add stub support for extension instructions
Jason Ekstrand [Wed, 29 Apr 2015 21:32:55 +0000 (14:32 -0700)]
nir/spirv: Add stub support for extension instructions

9 years agoREVERT: Add a simple helper program for testing SPIR-V -> NIR translation
Jason Ekstrand [Wed, 29 Apr 2015 21:29:38 +0000 (14:29 -0700)]
REVERT: Add a simple helper program for testing SPIR-V -> NIR translation

9 years agoglsl/compiler: Move the error_no_memory stub to standalone_scaffolding.cpp
Jason Ekstrand [Wed, 29 Apr 2015 21:30:22 +0000 (14:30 -0700)]
glsl/compiler: Move the error_no_memory stub to standalone_scaffolding.cpp

9 years agonir: Add the start of a SPIR-V to NIR translator
Jason Ekstrand [Wed, 29 Apr 2015 00:43:16 +0000 (17:43 -0700)]
nir: Add the start of a SPIR-V to NIR translator

At the moment, it can handle the very basics of strings and can ignore
debug instructions.  It also has basic support for decorations.

9 years agonir: Import the revision 30 SPIR-V header from Khronos
Jason Ekstrand [Tue, 28 Apr 2015 04:13:44 +0000 (21:13 -0700)]
nir: Import the revision 30 SPIR-V header from Khronos

9 years agovk/device: Use bias rather than layers for computing binding table size
Jason Ekstrand [Sat, 16 May 2015 17:42:51 +0000 (10:42 -0700)]
vk/device: Use bias rather than layers for computing binding table size

Because we statically use the first 8 binding table entries for render
targets, we need to create a table of size 8 + surfaces.

9 years agovk/meta: Make clear a no-op if no layers need clearing
Jason Ekstrand [Sat, 16 May 2015 17:23:43 +0000 (10:23 -0700)]
vk/meta: Make clear a no-op if no layers need clearing

Among other things, this prevents recursive meta.

9 years agovk/meta: Save and restore the old bindings pointer
Jason Ekstrand [Sat, 16 May 2015 17:28:04 +0000 (10:28 -0700)]
vk/meta: Save and restore the old bindings pointer

If we don't do this then recursive meta is completely broken.  What happens
is that the outer meta call may change the bindings pointer and the inner
meta call will change it again and, when it exits set it back to the
default.  However, the outer meta call may be relying on it being left
alone so it uses the non-meta descriptor sets instead of its own.

9 years agovk/device: Simplify surface_count calculation
Jason Ekstrand [Sat, 16 May 2015 17:23:09 +0000 (10:23 -0700)]
vk/device: Simplify surface_count calculation

9 years agovk/glsl_helpers: Fix GLSL_VK_SHADER with respect to commas
Jason Ekstrand [Sat, 16 May 2015 05:17:05 +0000 (22:17 -0700)]
vk/glsl_helpers: Fix GLSL_VK_SHADER with respect to commas

Previously, the GLSL_VK_SHADER macro didn't work if the shader contained
commas outside of parentheses due to the way the C preprocessor works.
This commit fixes this by making it variadic again and doing it correctly
this time.

9 years agovk: Make cmd_buffer->bindings a pointer
Kristian Høgsberg [Sat, 16 May 2015 00:03:18 +0000 (17:03 -0700)]
vk: Make cmd_buffer->bindings a pointer

This lets us save and restore efficiently by just moving the pointer to
a temporary bindings struct for meta.

9 years agovk: Move vertex buffers into struct anv_bindings
Kristian Høgsberg [Fri, 15 May 2015 23:34:31 +0000 (16:34 -0700)]
vk: Move vertex buffers into struct anv_bindings

9 years agovk: Fix GLSL_VK_SHADER macro
Kristian Høgsberg [Fri, 15 May 2015 23:15:04 +0000 (16:15 -0700)]
vk: Fix GLSL_VK_SHADER macro

Stringify doesn't work with __ARGV__. The last macro argument swallows
up excess arguments and as such we can just stringify that.

9 years agovk: Fix warning from missing initializer
Kristian Høgsberg [Fri, 15 May 2015 23:07:17 +0000 (16:07 -0700)]
vk: Fix warning from missing initializer

Struct initializers need to be { 0, } to zero out the variable they're
initializing.

9 years agovk: Build binding tables at bind descriptor time
Kristian Høgsberg [Fri, 15 May 2015 22:03:21 +0000 (15:03 -0700)]
vk: Build binding tables at bind descriptor time

This changes the way descriptor sets and layouts work so that we fill
out binding table contents at the time we bind descriptor sets. We
manipulate the binding table contents and sampler state in a shadow-copy
in anv_cmd_buffer. At draw time, we allocate the actual binding table
and sampler state and flush the anv_cmd_buffer copies.

9 years agovk: Update the bind map length to reflect MAX_SETS
Kristian Høgsberg [Fri, 15 May 2015 21:59:59 +0000 (14:59 -0700)]
vk: Update the bind map length to reflect MAX_SETS

9 years agovk: Flip back to using memfd for the allocators
Kristian Høgsberg [Thu, 14 May 2015 16:08:45 +0000 (09:08 -0700)]
vk: Flip back to using memfd for the allocators

9 years agovk: Rename dyn_state_pool to dynamic_state_pool
Kristian Høgsberg [Wed, 13 May 2015 22:34:34 +0000 (15:34 -0700)]
vk: Rename dyn_state_pool to dynamic_state_pool

Given that we already tolerate surface_state_pool and the even longer
instruction_state_pool, there's no reason to arbitrarily abbreviate
dynamic.

9 years agovk: Consolidate image, buffer and color attachment views
Kristian Høgsberg [Wed, 13 May 2015 22:31:26 +0000 (15:31 -0700)]
vk: Consolidate image, buffer and color attachment views

These are all just surface state, offset and a bo.

9 years agovk: Add a GLSL scraper utility
Jason Ekstrand [Fri, 15 May 2015 02:07:50 +0000 (19:07 -0700)]
vk: Add a GLSL scraper utility

This new utility, glsl_scraper.py scrapes C files for instances of the
GLSL_VK_SHADER macro, pulls out the shader source, and compiles it to
SPIR-V.  The compilation is done using glslValidator.  The result is then
placed into another C file as arrays of dwords that can be easiliy handed
to a Vulkan driver.

9 years agovk/meta: Add a magic GLSL shader source macro
Jason Ekstrand [Thu, 14 May 2015 18:58:58 +0000 (11:58 -0700)]
vk/meta: Add a magic GLSL shader source macro

9 years agovk/meta: Add a better comment about the VS for blits
Jason Ekstrand [Thu, 14 May 2015 18:39:32 +0000 (11:39 -0700)]
vk/meta: Add a better comment about the VS for blits

9 years agovk/test: Use VK_IMAGE_TILING_OPTIMAL for the render target
Jason Ekstrand [Thu, 14 May 2015 05:27:38 +0000 (22:27 -0700)]
vk/test: Use VK_IMAGE_TILING_OPTIMAL for the render target

9 years agovk/test: Do a copy of the RT into a linear buffer and write that to a PNG
Jason Ekstrand [Thu, 14 May 2015 05:18:37 +0000 (22:18 -0700)]
vk/test: Do a copy of the RT into a linear buffer and write that to a PNG

9 years agovk/meta: Add the start of a blit implementation
Jason Ekstrand [Thu, 14 May 2015 00:37:47 +0000 (17:37 -0700)]
vk/meta: Add the start of a blit implementation

Currently, we only implement CopyImageToBuffer

9 years agovk/pipeline: Default to a SamplerCount of 1 for PS
Jason Ekstrand [Thu, 14 May 2015 05:17:38 +0000 (22:17 -0700)]
vk/pipeline: Default to a SamplerCount of 1 for PS

9 years agovk/pipeline: Add an extra flag for force-disabling the vertex shader
Jason Ekstrand [Thu, 14 May 2015 05:16:04 +0000 (22:16 -0700)]
vk/pipeline: Add an extra flag for force-disabling the vertex shader

This way we can pass in a vertex shader and yet have the pipeline emit an
empty 3DSTATE_VS packet.  We need this for meta because we need to trick
the compiler into not deleting our inputs but at the same time disable the
VS so that we can use a rectlist.  This should go away once we actually get
SPIR-V.

9 years agovk/pass: Emit a flushing pipe control at the end of the pass
Jason Ekstrand [Thu, 14 May 2015 05:13:05 +0000 (22:13 -0700)]
vk/pass: Emit a flushing pipe control at the end of the pass

This is rather crude but it at least makes sure that all the render targets
get flushed at the end of the pass.  We probably actually want to do
somthing based on image layout traansitions, but this will work for now.

9 years agovk/compiler: Set the binding table texture_start
Jason Ekstrand [Thu, 14 May 2015 05:12:01 +0000 (22:12 -0700)]
vk/compiler: Set the binding table texture_start

This is by no means a complete solution to the binding table problems.
However, it does make texturing actually work.  Before, we were texturing
from the render target since they were both starting at 0.

9 years agovk/compiler: Zero the prog data
Jason Ekstrand [Thu, 14 May 2015 05:11:20 +0000 (22:11 -0700)]
vk/compiler: Zero the prog data

We use prog_data[stage] != NULL to determine whether or not we need to
clean up that stage.  Make sure it default to NULL.

9 years agovk/image: Stash more information in images and views
Jason Ekstrand [Thu, 14 May 2015 00:37:12 +0000 (17:37 -0700)]
vk/image: Stash more information in images and views

9 years agovk/meta: Save/restore more stuff in cmd_buffer_restore
Jason Ekstrand [Thu, 14 May 2015 00:34:37 +0000 (17:34 -0700)]
vk/meta: Save/restore more stuff in cmd_buffer_restore

9 years agovk: Install headers
Chad Versace [Thu, 14 May 2015 00:49:26 +0000 (17:49 -0700)]
vk: Install headers

I need this for building a testsuite.

9 years agovk: Add support for sampler descriptors
Kristian Høgsberg [Wed, 13 May 2015 21:43:08 +0000 (14:43 -0700)]
vk: Add support for sampler descriptors

9 years agovk: Use a typesafe anv_descriptor struct
Kristian Høgsberg [Wed, 13 May 2015 21:02:35 +0000 (14:02 -0700)]
vk: Use a typesafe anv_descriptor struct

9 years agovk: Create and bind a sampler in vk.c
Kristian Høgsberg [Wed, 13 May 2015 20:55:43 +0000 (13:55 -0700)]
vk: Create and bind a sampler in vk.c

9 years agovk: Fix copy-n-paste sType in vkCreateSampler
Kristian Høgsberg [Wed, 13 May 2015 20:53:01 +0000 (13:53 -0700)]
vk: Fix copy-n-paste sType in vkCreateSampler

9 years agovk: Add a dynamic state stream to anv_cmd_buffer
Kristian Høgsberg [Wed, 13 May 2015 20:51:08 +0000 (13:51 -0700)]
vk: Add a dynamic state stream to anv_cmd_buffer

We'll need this for sampler state.

9 years agovk: Move struct anv_sampler to private.h
Kristian Høgsberg [Wed, 13 May 2015 20:38:55 +0000 (13:38 -0700)]
vk: Move struct anv_sampler to private.h

9 years agovk: Allocate layout->count number of descriptors
Kristian Høgsberg [Wed, 13 May 2015 18:49:30 +0000 (11:49 -0700)]
vk: Allocate layout->count number of descriptors

layout->count is the number of descriptors the application
requested. layout->total is the number of entries we need across all
stages.

9 years agovk: Fill out sampler state from API values
Kristian Høgsberg [Wed, 13 May 2015 04:44:59 +0000 (21:44 -0700)]
vk: Fill out sampler state from API values

9 years agovk: Ignore vk executable
Chad Versace [Wed, 13 May 2015 19:05:38 +0000 (12:05 -0700)]
vk: Ignore vk executable

9 years agovk: Fix stale error handling in vkQueueSubmit
Kristian Høgsberg [Tue, 12 May 2015 21:38:58 +0000 (14:38 -0700)]
vk: Fix stale error handling in vkQueueSubmit

9 years agovk: Submit all cmd buffers passed to vkQueueSubmit
Kristian Høgsberg [Tue, 12 May 2015 21:38:12 +0000 (14:38 -0700)]
vk: Submit all cmd buffers passed to vkQueueSubmit

9 years agovk: Add generated header for HSW and IVB (GEN75 and GEN7)
Kristian Høgsberg [Tue, 12 May 2015 21:25:47 +0000 (14:25 -0700)]
vk: Add generated header for HSW and IVB (GEN75 and GEN7)

9 years agovk: Add stub() and stub_return() macros and mark piles of functions as stubs
Jason Ekstrand [Tue, 12 May 2015 20:44:43 +0000 (13:44 -0700)]
vk: Add stub() and stub_return() macros and mark piles of functions as stubs

9 years agovk/util: Add a anv_finishme function/macro
Jason Ekstrand [Tue, 12 May 2015 20:43:36 +0000 (13:43 -0700)]
vk/util: Add a anv_finishme function/macro

9 years agovk/meta: Break setting up meta clear state into it's own functin
Jason Ekstrand [Tue, 12 May 2015 20:03:50 +0000 (13:03 -0700)]
vk/meta: Break setting up meta clear state into it's own functin

9 years agovk/pipeline: Add support for disabling the scissor in "extra"
Jason Ekstrand [Tue, 12 May 2015 19:52:53 +0000 (12:52 -0700)]
vk/pipeline: Add support for disabling the scissor in "extra"

9 years agovk: Add clear load-op for render passes
Kristian Høgsberg [Tue, 12 May 2015 06:25:06 +0000 (23:25 -0700)]
vk: Add clear load-op for render passes

9 years agovk: Add support for driver-internal custom pipelines
Kristian Høgsberg [Tue, 12 May 2015 06:20:01 +0000 (23:20 -0700)]
vk: Add support for driver-internal custom pipelines

This lets us disable the viewport, use rect lists and repclear.

9 years agovk: Fix 3DSTATE_VERTEX_BUFFER emission
Kristian Høgsberg [Tue, 12 May 2015 05:25:52 +0000 (22:25 -0700)]
vk: Fix 3DSTATE_VERTEX_BUFFER emission

Set VertexBufferIndex to the attribute binding, not the location.

9 years agovk: Add 32 bpc signed and unsigned integer formats
Kristian Høgsberg [Tue, 12 May 2015 05:24:57 +0000 (22:24 -0700)]
vk: Add 32 bpc signed and unsigned integer formats

9 years agovk: Add anv_batch_emit_merge() helper macro
Kristian Høgsberg [Tue, 12 May 2015 05:23:38 +0000 (22:23 -0700)]
vk: Add anv_batch_emit_merge() helper macro

This lets us emit a state packet by merging to half-backed versions,
typically one from the pipeline object and one from a dynamic state
objects.

9 years agovk: Store bo pointer in anv_image and anv_buffer
Kristian Høgsberg [Tue, 12 May 2015 05:19:58 +0000 (22:19 -0700)]
vk: Store bo pointer in anv_image and anv_buffer

We don't need to point back to the memory object the bo came from.
Pointing directly to a bo lets us bind images and buffers to other
bos - like our allocator bos.

9 years agovk: Support not having a vertex shader
Kristian Høgsberg [Tue, 12 May 2015 05:17:04 +0000 (22:17 -0700)]
vk: Support not having a vertex shader

This lets us bypass the vertex shader and pass data straight into
the rasterizer part of the pipeline.

9 years agovk: Allow NULL as a valid pipeline layout
Kristian Høgsberg [Tue, 12 May 2015 05:12:56 +0000 (22:12 -0700)]
vk: Allow NULL as a valid pipeline layout

Vertex buffers and render targets aren't part of the layout so having
an empty layout is pretty common.

9 years agoAdd vulkan driver for BDW
Kristian Høgsberg [Sat, 9 May 2015 05:32:37 +0000 (22:32 -0700)]
Add vulkan driver for BDW

9 years agonir: Fix aggressive typos in nir_from_ssa.c.
Kenneth Graunke [Sat, 9 May 2015 02:36:19 +0000 (19:36 -0700)]
nir: Fix aggressive typos in nir_from_ssa.c.

s/agressive/aggressive/g

Trivial.

9 years agonir/search: Save/restore the variables_seen bitmask when matching
Jason Ekstrand [Fri, 8 May 2015 16:48:33 +0000 (09:48 -0700)]
nir/search: Save/restore the variables_seen bitmask when matching

Shader-db results on Broadwell:

   total instructions in shared programs: 7152330 -> 7137006 (-0.21%)
   instructions in affected programs:     1330548 -> 1315224 (-1.15%)
   helped:                                5797
   HURT:                                  76
   GAINED:                                0
   LOST:                                  8

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
9 years agonir/search: Assert that variable id's are in range
Jason Ekstrand [Fri, 8 May 2015 16:42:05 +0000 (09:42 -0700)]
nir/search: Assert that variable id's are in range

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
9 years agonir/search: handle explicitly sized sources in match_value
Jason Ekstrand [Fri, 8 May 2015 15:33:01 +0000 (08:33 -0700)]
nir/search: handle explicitly sized sources in match_value

Previously, this case was being handled in match_expression prior to
calling match_value.  However, there is really no good reason for this
given that match_value has all of the information it needs.  Also, they
weren't being handled properly in the commutative case and putting it in
match_value gives us that for free.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
9 years agonir/nir: Use a linked list instead of a hash set for use/def sets
Jason Ekstrand [Fri, 24 Apr 2015 17:16:27 +0000 (10:16 -0700)]
nir/nir: Use a linked list instead of a hash set for use/def sets

This commit switches us from the current setup of using hash sets for
use/def sets to using linked lists.  Doing so should save us quite a bit of
memory because we aren't carrying around 3 hash sets per register and 2 per
SSA value.  It should also save us CPU time because adding/removing things
from use/def sets is 4 pointer manipulations instead of a hash lookup.

Running shader-db 50 times with USE_NIR=0, NIR, and NIR + use/def lists:

   GLSL IR Only:        586.4 +/- 1.653833
   NIR with hash sets:  675.4 +/- 2.502108
   NIR + use/def lists: 641.2 +/- 1.557043

I also ran a memory usage experiment with Ken's patch to delete GLSL IR and
keep NIR.  This patch cuts an aditional 42.9 MiB of ralloc'd memory over
and above what we gained by deleting the GLSL IR on the same dota trace.

On the code complexity side of things, some things are now much easier and
others are a bit harder.  One of the operations we perform constantly in
optimization passes is to replace one source with another.  Due to the fact
that an instruction can use the same SSA value multiple times, we had to
iterate through the sources of the instruction and determine if the use we
were replacing was the only one before removing it from the set of uses.
With this patch, uses are per-source not per-instruction so we can just
remove it safely.  On the other hand, trying to iterate over all of the
instructions that use a given value is more difficult.  Fortunately, the
two places we do that are the ffma peephole where it doesn't matter and GCM
where we already gracefully handle duplicates visits to an instruction.

Another aspect here is that using linked lists in this way can be tricky to
get right.  With sets, things were quite forgiving and the worst that
happened if you didn't properly remove a use was that it would get caught
in the validator.  With linked lists, it can lead to linked list corruption
which can be harder to track.  However, we do just as much validation of
the linked lists as we did of the sets so the validator should still catch
these problems.  While working on this series, the vast majority of the
bugs I had to fix were caught by assertions.  I don't think the lists are
going to be that much worse than the sets.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
9 years agoutil/list: Add a list validation function
Jason Ekstrand [Tue, 28 Apr 2015 03:40:11 +0000 (20:40 -0700)]
util/list: Add a list validation function

Acked-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Rob Clark <robclark@freedesktop.org>