Commit Graph

78 Commits

Author SHA1 Message Date
Jason Ekstrand dcb6a68bb4 anv: Move shader hashing to anv_pipeline
Shader hashing is very closely related to shader compilation.  Putting
them right next to each other in anv_pipeline makes it easier to verify
that we're actually hashing everything we need to be hashing.  The only
real change (other than the order of hashing) is that we now hash in the
shader stage.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2017-05-03 11:25:46 -07:00
Jason Ekstrand d4d9258b61 anv/physical_device: Rename uuid to pipeline_cache_uuid
We're about to have more UUIDs for different things so this one really
needs to be properly labeled.

Reviewed-by: Chad Versace <chadversary@chromium.org>
2017-04-27 20:08:46 -07:00
Iago Toral Quiroga 88b539c4a0 anv: do not try to ref/unref NULL shaders
This situation can happen if we failed to allocate memory for the shader.

v2:
 - We shouldn't see NULL shaders in anv_shader_bin_ref so we should not check
   for that (Jason). Make sure that callers don't attempt to call this
   function with a NULL shader and assert that this never happens (Iago).

v3:
 - All callers to anv_shader_bin_unref seem to check for NULL before calling,
   so just assert that it is not NULL (Topi)

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2017-03-16 11:40:05 +01:00
Emil Velikov a9a4028fd7 util/sha1: rework _mesa_sha1_{init,final}
Rather than having an extra memory allocation [that we currently do not
and act accordingly] just make the API take an pointer to a stack
allocated instance.

This and follow-up steps will effectively make the _mesa_sha1_foo simple
define/inlines around their SHA1 counterparts.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Grazvydas Ignotas <notasas@gmail.com>
2017-03-15 11:18:43 +00:00
Emil Velikov de138e9ced anv: Store UUID in physical device.
Port of an equivalent commit for radv.

v2: Move the call just after MMAP_VERSION (Ken).

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-11-28 19:46:05 +00:00
Jason Ekstrand 49f08ad77f anv: Handle null in all destructors
This fixes a bunch of new CTS tests which look for exactly this.  Even in
the cases where we just call vk_free to free a CPU data structure, we still
handle NULL explicitly.  This way we're less likely to forget to handle
NULL later should we actually do something less trivial.

Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-11-16 20:07:23 -08:00
Jason Ekstrand 71cc1e188d anv/pipeline: Properly cache prog_data::param
Before we were caching the prog data but we weren't doing anything with
brw_stage_prog_data::param so anything with push constants wasn't getting
cached properly.  This commit fixes that.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98012
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
2016-11-02 09:32:28 -07:00
Jason Ekstrand ff3185e3ba anv/pipeline: Put actual pointers in anv_shader_bin
While we can simply calculate offsets to get to things such as the
prog_data and the key, it's much more user-friendly if there are just
pointers.  Also, it's a bit more fool-proof.

While we're at it, we rework the pipeline cache API to use the
brw_stage_prog_data type directly.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98012
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
2016-11-02 09:32:22 -07:00
Dave Airlie 1ae6ece980 anv: move to using vk_alloc helpers.
This moves all the alloc/free in anv to the generic helpers.

Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2016-10-19 09:05:26 +10:00
Lionel Landwerlin eb23de6116 anv: pipeline cache: fix return value of vkGetPipelineCacheData
According to the spec - 9.6. Pipeline Cache :

  If pDataSize is less than the maximum size that can be retrieved by the
  pipeline cache, at most pDataSize bytes will be written to pData, and
  vkGetPipelineCacheData will return VK_INCOMPLETE.

Fixes the following test from Vulkan CTS :

  dEQP-VK.pipeline.cache.pipeline_from_incomplete_get_data.vertex_stage_fragment_stage
  dEQP-VK.pipeline.cache.pipeline_from_incomplete_get_data.vertex_stage_geometry_stage_fragment_stage
  dEQP-VK.pipeline.cache.misc_tests.invalid_size_test

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-10-07 18:46:12 +01:00
Jason Ekstrand 10f9901bce anv: Rework pipeline caching
The original pipeline cache the Kristian wrote was based on a now-false
premise that the shaders can be stored in the pipeline cache.  The Vulkan
1.0 spec explicitly states that the pipeline cache object is transiant and
you are allowed to delete it after using it to create a pipeline with no
ill effects.  As nice as Kristian's design was, it doesn't jive with the
expectation provided by the Vulkan spec.

The new pipeline cache uses reference-counted anv_shader_bin objects that
are backed by a large state pool.  The cache itself is just a hash table
mapping keys hashes to anv_shader_bin objects.  This has the added
advantage of removing one more hand-rolled hash table from mesa.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97476
Acked-by: Kristian Høgsberg Kristensen <krh@bitplanet.net>
2016-08-30 15:08:23 -07:00
Jason Ekstrand 6899718470 anv: Add a struct for storing a compiled shader
This new anv_shader_bin struct stores the compiled kernel (as an anv_state)
as well as all of the metadata that is generated at shader compile time.
The struct is very similar to the old cache_entry struct except that it
is reference counted and stores the actual pipeline_bind_map.  Similarly to
cache_entry, much of the actual data is floating-size and stored after the
main struct.  Unlike cache_entry, which was storred in GPU-accessable
memory, the storage for anv_shader_bin kernels comes from a state pool.
The struct itself is reference-counted so that it can be used by multiple
pipelines at a time without fear of allocation issues.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Acked-by: Kristian Høgsberg Kristensen <krh@bitplanet.net>
2016-08-30 15:08:23 -07:00
Jason Ekstrand 2301705dee anv: Include the pipeline layout in the shader hash
The pipeline layout affects shader compilation because it is what
determines binding table locations as well as whether or not a particular
buffer has dynamic offsets.  Since this affects the generated shader, it
needs to be in the hash.  This fixes a bunch of CTS tests now that the CTS
is using a pipeline cache.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
2016-08-24 20:42:05 -07:00
Jason Ekstrand 4f5bbf804b anv/pipeline_cache: Allow for an zero-sized cache
This gets ANV_ENABLE_PIPELINE_CACHE=false working again.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
2016-06-10 09:43:10 -07:00
Jason Ekstrand ffcef720b7 anv/pipeline: Add support for caching the push constant map
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2016-06-06 00:44:32 -07:00
Kristian Høgsberg Kristensen 34326f46df anv: Turn pipeline cache on by default
Move the environment variable check to cache creation time so we block
both lookups and uploads if it's turned off.
2016-03-05 13:54:24 -08:00
Kristian Høgsberg Kristensen f2b37132cb anv: Check if shader if present before uploading to cache
Between the initial check the returns NO_KERNEL and compiling the
shader, other threads may have added the shader to the cache. Before
uploading the kernel, check again (under the mutex) that the compiled
shader still isn't present.
2016-03-05 13:54:24 -08:00
Kristian Høgsberg Kristensen 6139fe9a77 anv: Also cache the struct anv_pipeline_binding maps
This is state the we generate when compiling the shaders and we need it
for mapping resources from descriptor sets to binding table indices.
2016-03-05 13:50:07 -08:00
Kristian Høgsberg Kristensen 584f39c65e anv: Don't re-upload shaders when merging
Using anv_pipeline_cache_upload_kernel() will re-upload the kernel and
prog_data when we merge caches. Since the kernel and prog_data is
already in the program_stream, use anv_pipeline_cache_add_entry()
instead to only add the entry to the hash table.
2016-03-05 13:50:07 -08:00
Kristian Høgsberg Kristensen 626559ed37 anv: Add anv_pipeline_cache_add_entry()
This function will grow the cache to make room and then add the entry.
2016-03-05 13:50:07 -08:00
Kristian Høgsberg Kristensen 07441c344c anv: Rename anv_pipeline_cache_add_entry() to 'set'
This function is a helper that unconditionally sets a hash table entry
and expects the cache to have enough room. Calling it 'add_entry'
suggests it will grow the cache as needed.
2016-03-05 13:50:07 -08:00
Kristian Høgsberg Kristensen 2b29342fae anv: Store prog data in pipeline cache stream
We have to keep it there for the cache to work, so let's not have an
extra copy in struct anv_pipeline too.
2016-03-05 13:50:07 -08:00
Kristian Høgsberg Kristensen 37c5e70253 anv: Rename 'table' to 'hash_table' in anv_pipeline_cache
A little less ambiguous.
2016-03-05 13:50:07 -08:00
Kristian Høgsberg Kristensen c028ffea70 anv: Serialize as much pipeline cache as we can
We can serialize as much as the application asks for and just stop once
we run out of memory. This lets applications use a fixed amount of
space for caching and still get some benefit.
2016-03-05 13:50:07 -08:00
Kristian Høgsberg Kristensen cd812f086e anv: Use 1.0 pipeline cache header
The final version of the pipeline cache header adds a few more fields.
2016-03-05 13:50:07 -08:00
Kristian Høgsberg Kristensen 26ed943eb9 anv: Fix shader key hashing
This was copied from inline code to a helper and wasn't updated to hash
a pointer instead.
2016-03-05 13:50:07 -08:00
Kristian Høgsberg Kristensen 3baf8af947 anv: Remove excess whitespace 2016-03-05 13:50:07 -08:00
Jason Ekstrand 9851c8285f Move the intel vulkan driver to src/intel/vulkan 2016-02-18 10:37:59 -08:00
Renamed from src/vulkan/anv_pipeline_cache.c (Browse further)