freedreno/registers: a6xx depth bounds test registers
[mesa.git] / src / freedreno / vulkan / tu_pipeline_cache.c
index 32470b75aa0a9024d241fb192fab1c237e80392f..47a8b97283fba40a4067fad975b350c265d6f435 100644 (file)
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
 #include "tu_private.h"
+
 #include "util/debug.h"
 #include "util/disk_cache.h"
 #include "util/mesa-sha1.h"
@@ -33,8 +34,7 @@ struct cache_entry_variant_info
 
 struct cache_entry
 {
-   union
-   {
+   union {
       unsigned char sha1[20];
       uint32_t sha1_dw[5];
    };
@@ -43,9 +43,9 @@ struct cache_entry
    char code[0];
 };
 
-void
+static void
 tu_pipeline_cache_init(struct tu_pipeline_cache *cache,
-                        struct tu_device *device)
+                       struct tu_device *device)
 {
    cache->device = device;
    pthread_mutex_init(&cache->mutex, NULL);
@@ -66,7 +66,7 @@ tu_pipeline_cache_init(struct tu_pipeline_cache *cache,
       memset(cache->hash_table, 0, byte_size);
 }
 
-void
+static void
 tu_pipeline_cache_finish(struct tu_pipeline_cache *cache)
 {
    for (unsigned i = 0; i < cache->table_size; ++i)
@@ -83,51 +83,17 @@ entry_size(struct cache_entry *entry)
    size_t ret = sizeof(*entry);
    for (int i = 0; i < MESA_SHADER_STAGES; ++i)
       if (entry->code_sizes[i])
-         ret += sizeof(struct cache_entry_variant_info) + entry->code_sizes[i];
+         ret +=
+            sizeof(struct cache_entry_variant_info) + entry->code_sizes[i];
    return ret;
 }
 
-void
-tu_hash_shaders(unsigned char *hash,
-                 const VkPipelineShaderStageCreateInfo **stages,
-                 const struct tu_pipeline_layout *layout,
-                 const struct tu_pipeline_key *key,
-                 uint32_t flags)
-{
-   struct mesa_sha1 ctx;
-
-   _mesa_sha1_init(&ctx);
-   if (key)
-      _mesa_sha1_update(&ctx, key, sizeof(*key));
-   if (layout)
-      _mesa_sha1_update(&ctx, layout->sha1, sizeof(layout->sha1));
-
-   for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
-      if (stages[i]) {
-         TU_FROM_HANDLE(tu_shader_module, module, stages[i]->module);
-         const VkSpecializationInfo *spec_info = stages[i]->pSpecializationInfo;
-
-         _mesa_sha1_update(&ctx, module->sha1, sizeof(module->sha1));
-         _mesa_sha1_update(&ctx, stages[i]->pName, strlen(stages[i]->pName));
-         if (spec_info) {
-            _mesa_sha1_update(&ctx,
-                              spec_info->pMapEntries,
-                              spec_info->mapEntryCount *
-                                sizeof spec_info->pMapEntries[0]);
-            _mesa_sha1_update(&ctx, spec_info->pData, spec_info->dataSize);
-         }
-      }
-   }
-   _mesa_sha1_update(&ctx, &flags, 4);
-   _mesa_sha1_final(&ctx, hash);
-}
-
 static struct cache_entry *
 tu_pipeline_cache_search_unlocked(struct tu_pipeline_cache *cache,
-                                   const unsigned char *sha1)
+                                  const unsigned char *sha1)
 {
    const uint32_t mask = cache->table_size - 1;
-   const uint32_t start = (*(uint32_t *)sha1);
+   const uint32_t start = (*(uint32_t *) sha1);
 
    if (cache->table_size == 0)
       return NULL;
@@ -149,7 +115,7 @@ tu_pipeline_cache_search_unlocked(struct tu_pipeline_cache *cache,
 
 static struct cache_entry *
 tu_pipeline_cache_search(struct tu_pipeline_cache *cache,
-                          const unsigned char *sha1)
+                         const unsigned char *sha1)
 {
    struct cache_entry *entry;
 
@@ -164,7 +130,7 @@ tu_pipeline_cache_search(struct tu_pipeline_cache *cache,
 
 static void
 tu_pipeline_cache_set_entry(struct tu_pipeline_cache *cache,
-                             struct cache_entry *entry)
+                            struct cache_entry *entry)
 {
    const uint32_t mask = cache->table_size - 1;
    const uint32_t start = entry->sha1_dw[0];
@@ -218,7 +184,7 @@ tu_pipeline_cache_grow(struct tu_pipeline_cache *cache)
 
 static void
 tu_pipeline_cache_add_entry(struct tu_pipeline_cache *cache,
-                             struct cache_entry *entry)
+                            struct cache_entry *entry)
 {
    if (cache->kernel_count == cache->table_size / 2)
       tu_pipeline_cache_grow(cache);
@@ -239,10 +205,10 @@ struct cache_header
    uint8_t uuid[VK_UUID_SIZE];
 };
 
-void
+static void
 tu_pipeline_cache_load(struct tu_pipeline_cache *cache,
-                        const void *data,
-                        size_t size)
+                       const void *data,
+                       size_t size)
 {
    struct tu_device *device = cache->device;
    struct cache_header header;
@@ -258,22 +224,22 @@ tu_pipeline_cache_load(struct tu_pipeline_cache *cache,
       return;
    if (header.device_id != 0 /* TODO */)
       return;
-   if (memcmp(header.uuid, device->physical_device->cache_uuid, VK_UUID_SIZE) !=
-       0)
+   if (memcmp(header.uuid, device->physical_device->cache_uuid,
+              VK_UUID_SIZE) != 0)
       return;
 
-   char *end = (void *)data + size;
-   char *p = (void *)data + header.header_size;
+   char *end = (void *) data + size;
+   char *p = (void *) data + header.header_size;
 
    while (end - p >= sizeof(struct cache_entry)) {
-      struct cache_entry *entry = (struct cache_entry *)p;
+      struct cache_entry *entry = (struct cache_entry *) p;
       struct cache_entry *dest_entry;
       size_t size = entry_size(entry);
       if (end - p < size)
          break;
 
       dest_entry =
-        vk_alloc(&cache->alloc, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_CACHE);
+         vk_alloc(&cache->alloc, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_CACHE);
       if (dest_entry) {
          memcpy(dest_entry, entry, size);
          for (int i = 0; i < MESA_SHADER_STAGES; ++i)
@@ -286,9 +252,9 @@ tu_pipeline_cache_load(struct tu_pipeline_cache *cache,
 
 VkResult
 tu_CreatePipelineCache(VkDevice _device,
-                        const VkPipelineCacheCreateInfo *pCreateInfo,
-                        const VkAllocationCallbacks *pAllocator,
-                        VkPipelineCache *pPipelineCache)
+                       const VkPipelineCacheCreateInfo *pCreateInfo,
+                       const VkAllocationCallbacks *pAllocator,
+                       VkPipelineCache *pPipelineCache)
 {
    TU_FROM_HANDLE(tu_device, device, _device);
    struct tu_pipeline_cache *cache;
@@ -296,10 +262,7 @@ tu_CreatePipelineCache(VkDevice _device,
    assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO);
    assert(pCreateInfo->flags == 0);
 
-   cache = vk_alloc2(&device->alloc,
-                     pAllocator,
-                     sizeof(*cache),
-                     8,
+   cache = vk_alloc2(&device->alloc, pAllocator, sizeof(*cache), 8,
                      VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
    if (cache == NULL)
       return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -312,8 +275,8 @@ tu_CreatePipelineCache(VkDevice _device,
    tu_pipeline_cache_init(cache, device);
 
    if (pCreateInfo->initialDataSize > 0) {
-      tu_pipeline_cache_load(
-        cache, pCreateInfo->pInitialData, pCreateInfo->initialDataSize);
+      tu_pipeline_cache_load(cache, pCreateInfo->pInitialData,
+                             pCreateInfo->initialDataSize);
    }
 
    *pPipelineCache = tu_pipeline_cache_to_handle(cache);
@@ -323,8 +286,8 @@ tu_CreatePipelineCache(VkDevice _device,
 
 void
 tu_DestroyPipelineCache(VkDevice _device,
-                         VkPipelineCache _cache,
-                         const VkAllocationCallbacks *pAllocator)
+                        VkPipelineCache _cache,
+                        const VkAllocationCallbacks *pAllocator)
 {
    TU_FROM_HANDLE(tu_device, device, _device);
    TU_FROM_HANDLE(tu_pipeline_cache, cache, _cache);
@@ -338,9 +301,9 @@ tu_DestroyPipelineCache(VkDevice _device,
 
 VkResult
 tu_GetPipelineCacheData(VkDevice _device,
-                         VkPipelineCache _cache,
-                         size_t *pDataSize,
-                         void *pData)
+                        VkPipelineCache _cache,
+                        size_t *pDataSize,
+                        void *pData)
 {
    TU_FROM_HANDLE(tu_device, device, _device);
    TU_FROM_HANDLE(tu_pipeline_cache, cache, _cache);
@@ -382,7 +345,7 @@ tu_GetPipelineCacheData(VkDevice _device,
 
       memcpy(p, entry, size);
       for (int j = 0; j < MESA_SHADER_STAGES; ++j)
-         ((struct cache_entry *)p)->variants[j] = NULL;
+         ((struct cache_entry *) p)->variants[j] = NULL;
       p += size;
    }
    *pDataSize = p - pData;
@@ -393,7 +356,7 @@ tu_GetPipelineCacheData(VkDevice _device,
 
 static void
 tu_pipeline_cache_merge(struct tu_pipeline_cache *dst,
-                         struct tu_pipeline_cache *src)
+                        struct tu_pipeline_cache *src)
 {
    for (uint32_t i = 0; i < src->table_size; i++) {
       struct cache_entry *entry = src->hash_table[i];
@@ -408,9 +371,9 @@ tu_pipeline_cache_merge(struct tu_pipeline_cache *dst,
 
 VkResult
 tu_MergePipelineCaches(VkDevice _device,
-                        VkPipelineCache destCache,
-                        uint32_t srcCacheCount,
-                        const VkPipelineCache *pSrcCaches)
+                       VkPipelineCache destCache,
+                       uint32_t srcCacheCount,
+                       const VkPipelineCache *pSrcCaches)
 {
    TU_FROM_HANDLE(tu_pipeline_cache, dst, destCache);