.pfnFree = default_free
};
-VkResult VKAPI vkCreateInstance(
+VkResult anv_CreateInstance(
const VkInstanceCreateInfo* pCreateInfo,
VkInstance* pInstance)
{
return VK_SUCCESS;
}
-VkResult VKAPI vkDestroyInstance(
+VkResult anv_DestroyInstance(
VkInstance _instance)
{
struct anv_instance *instance = (struct anv_instance *) _instance;
return VK_SUCCESS;
}
-VkResult VKAPI vkEnumeratePhysicalDevices(
+VkResult anv_EnumeratePhysicalDevices(
VkInstance _instance,
uint32_t* pPhysicalDeviceCount,
VkPhysicalDevice* pPhysicalDevices)
return VK_SUCCESS;
}
-VkResult VKAPI vkGetPhysicalDeviceInfo(
+VkResult anv_GetPhysicalDeviceInfo(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceInfoType infoType,
size_t* pDataSize,
VkPhysicalDevice physicalDevice,
const char* pName)
{
- return NULL;
+ return anv_lookup_entrypoint(pName);
}
static void
}
}
-VkResult VKAPI vkCreateDevice(
+VkResult anv_CreateDevice(
VkPhysicalDevice _physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
VkDevice* pDevice)
return vk_error(VK_ERROR_UNAVAILABLE);
}
-VkResult VKAPI vkDestroyDevice(
+VkResult anv_DestroyDevice(
VkDevice _device)
{
struct anv_device *device = (struct anv_device *) _device;
return VK_SUCCESS;
}
-VkResult VKAPI vkGetGlobalExtensionInfo(
+VkResult anv_GetGlobalExtensionInfo(
VkExtensionInfoType infoType,
uint32_t extensionIndex,
size_t* pDataSize,
}
}
-VkResult VKAPI vkGetPhysicalDeviceExtensionInfo(
+VkResult anv_GetPhysicalDeviceExtensionInfo(
VkPhysicalDevice physicalDevice,
VkExtensionInfoType infoType,
uint32_t extensionIndex,
}
}
-VkResult VKAPI vkEnumerateLayers(
+VkResult anv_EnumerateLayers(
VkPhysicalDevice physicalDevice,
size_t maxStringSize,
size_t* pLayerCount,
return VK_SUCCESS;
}
-VkResult VKAPI vkGetDeviceQueue(
+VkResult anv_GetDeviceQueue(
VkDevice _device,
uint32_t queueNodeIndex,
uint32_t queueIndex,
location - batch->bo.map, bo, delta);
}
-VkResult VKAPI vkQueueSubmit(
+VkResult anv_QueueSubmit(
VkQueue _queue,
uint32_t cmdBufferCount,
const VkCmdBuffer* pCmdBuffers,
return VK_SUCCESS;
}
-VkResult VKAPI vkQueueAddMemReferences(
+VkResult anv_QueueAddMemReferences(
VkQueue queue,
uint32_t count,
const VkDeviceMemory* pMems)
return VK_SUCCESS;
}
-VkResult VKAPI vkQueueRemoveMemReferences(
+VkResult anv_QueueRemoveMemReferences(
VkQueue queue,
uint32_t count,
const VkDeviceMemory* pMems)
return VK_SUCCESS;
}
-VkResult VKAPI vkQueueWaitIdle(
+VkResult anv_QueueWaitIdle(
VkQueue _queue)
{
struct anv_queue *queue = (struct anv_queue *) _queue;
return vkDeviceWaitIdle((VkDevice) queue->device);
}
-VkResult VKAPI vkDeviceWaitIdle(
+VkResult anv_DeviceWaitIdle(
VkDevice _device)
{
struct anv_device *device = (struct anv_device *) _device;
return VK_SUCCESS;
}
-VkResult VKAPI vkAllocMemory(
+VkResult anv_AllocMemory(
VkDevice _device,
const VkMemoryAllocInfo* pAllocInfo,
VkDeviceMemory* pMem)
return result;
}
-VkResult VKAPI vkFreeMemory(
+VkResult anv_FreeMemory(
VkDevice _device,
VkDeviceMemory _mem)
{
return VK_SUCCESS;
}
-VkResult VKAPI vkSetMemoryPriority(
+VkResult anv_SetMemoryPriority(
VkDevice device,
VkDeviceMemory mem,
VkMemoryPriority priority)
return VK_SUCCESS;
}
-VkResult VKAPI vkMapMemory(
+VkResult anv_MapMemory(
VkDevice _device,
VkDeviceMemory _mem,
VkDeviceSize offset,
return VK_SUCCESS;
}
-VkResult VKAPI vkUnmapMemory(
+VkResult anv_UnmapMemory(
VkDevice _device,
VkDeviceMemory _mem)
{
return VK_SUCCESS;
}
-VkResult VKAPI vkFlushMappedMemory(
+VkResult anv_FlushMappedMemory(
VkDevice device,
VkDeviceMemory mem,
VkDeviceSize offset,
return VK_SUCCESS;
}
-VkResult VKAPI vkPinSystemMemory(
+VkResult anv_PinSystemMemory(
VkDevice device,
const void* pSysMem,
size_t memSize,
return VK_SUCCESS;
}
-VkResult VKAPI vkGetMultiDeviceCompatibility(
+VkResult anv_GetMultiDeviceCompatibility(
VkPhysicalDevice physicalDevice0,
VkPhysicalDevice physicalDevice1,
VkPhysicalDeviceCompatibilityInfo* pInfo)
return VK_UNSUPPORTED;
}
-VkResult VKAPI vkOpenSharedMemory(
+VkResult anv_OpenSharedMemory(
VkDevice device,
const VkMemoryOpenInfo* pOpenInfo,
VkDeviceMemory* pMem)
return VK_UNSUPPORTED;
}
-VkResult VKAPI vkOpenSharedSemaphore(
+VkResult anv_OpenSharedSemaphore(
VkDevice device,
const VkSemaphoreOpenInfo* pOpenInfo,
VkSemaphore* pSemaphore)
return VK_UNSUPPORTED;
}
-VkResult VKAPI vkOpenPeerMemory(
+VkResult anv_OpenPeerMemory(
VkDevice device,
const VkPeerMemoryOpenInfo* pOpenInfo,
VkDeviceMemory* pMem)
return VK_UNSUPPORTED;
}
-VkResult VKAPI vkOpenPeerImage(
+VkResult anv_OpenPeerImage(
VkDevice device,
const VkPeerImageOpenInfo* pOpenInfo,
VkImage* pImage,
[VK_OBJECT_TYPE_RENDER_PASS] = anv_free_destructor
};
-VkResult VKAPI vkDestroyObject(
+VkResult anv_DestroyObject(
VkDevice _device,
VkObjectType objType,
VkObject object)
}
}
-VkResult VKAPI vkGetObjectInfo(
+VkResult anv_GetObjectInfo(
VkDevice _device,
VkObjectType objType,
VkObject object,
}
-VkResult VKAPI vkQueueBindObjectMemory(
+VkResult anv_QueueBindObjectMemory(
VkQueue queue,
VkObjectType objType,
VkObject object,
return VK_SUCCESS;
}
-VkResult VKAPI vkQueueBindObjectMemoryRange(
+VkResult anv_QueueBindObjectMemoryRange(
VkQueue queue,
VkObjectType objType,
VkObject object,
stub_return(VK_UNSUPPORTED);
}
-VkResult vkQueueBindImageMemoryRange(
+VkResult anv_QueueBindImageMemoryRange(
VkQueue queue,
VkImage image,
uint32_t allocationIdx,
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkCreateFence(
+VkResult anv_CreateFence(
VkDevice device,
const VkFenceCreateInfo* pCreateInfo,
VkFence* pFence)
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkResetFences(
+VkResult anv_ResetFences(
VkDevice device,
uint32_t fenceCount,
VkFence* pFences)
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkGetFenceStatus(
+VkResult anv_GetFenceStatus(
VkDevice device,
VkFence fence)
{
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkWaitForFences(
+VkResult anv_WaitForFences(
VkDevice device,
uint32_t fenceCount,
const VkFence* pFences,
// Queue semaphore functions
-VkResult VKAPI vkCreateSemaphore(
+VkResult anv_CreateSemaphore(
VkDevice device,
const VkSemaphoreCreateInfo* pCreateInfo,
VkSemaphore* pSemaphore)
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkQueueSignalSemaphore(
+VkResult anv_QueueSignalSemaphore(
VkQueue queue,
VkSemaphore semaphore)
{
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkQueueWaitSemaphore(
+VkResult anv_QueueWaitSemaphore(
VkQueue queue,
VkSemaphore semaphore)
{
// Event functions
-VkResult VKAPI vkCreateEvent(
+VkResult anv_CreateEvent(
VkDevice device,
const VkEventCreateInfo* pCreateInfo,
VkEvent* pEvent)
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkGetEventStatus(
+VkResult anv_GetEventStatus(
VkDevice device,
VkEvent event)
{
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkSetEvent(
+VkResult anv_SetEvent(
VkDevice device,
VkEvent event)
{
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkResetEvent(
+VkResult anv_ResetEvent(
VkDevice device,
VkEvent event)
{
struct anv_bo bo;
};
-VkResult VKAPI vkCreateQueryPool(
+VkResult anv_CreateQueryPool(
VkDevice _device,
const VkQueryPoolCreateInfo* pCreateInfo,
VkQueryPool* pQueryPool)
return result;
}
-VkResult VKAPI vkGetQueryPoolResults(
+VkResult anv_GetQueryPoolResults(
VkDevice device,
VkQueryPool queryPool,
uint32_t startQuery,
// Format capabilities
-VkResult VKAPI vkGetFormatInfo(
+VkResult anv_GetFormatInfo(
VkDevice device,
VkFormat format,
VkFormatInfoType infoType,
// Buffer functions
-VkResult VKAPI vkCreateBuffer(
+VkResult anv_CreateBuffer(
VkDevice _device,
const VkBufferCreateInfo* pCreateInfo,
VkBuffer* pBuffer)
// Buffer view functions
-VkResult VKAPI vkCreateBufferView(
+VkResult anv_CreateBufferView(
VkDevice _device,
const VkBufferViewCreateInfo* pCreateInfo,
VkBufferView* pView)
// Sampler functions
-VkResult VKAPI vkCreateSampler(
+VkResult anv_CreateSampler(
VkDevice _device,
const VkSamplerCreateInfo* pCreateInfo,
VkSampler* pSampler)
// Descriptor set functions
-VkResult VKAPI vkCreateDescriptorSetLayout(
+VkResult anv_CreateDescriptorSetLayout(
VkDevice _device,
const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
VkDescriptorSetLayout* pSetLayout)
return VK_SUCCESS;
}
-VkResult VKAPI vkBeginDescriptorPoolUpdate(
+VkResult anv_BeginDescriptorPoolUpdate(
VkDevice device,
VkDescriptorUpdateMode updateMode)
{
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkEndDescriptorPoolUpdate(
+VkResult anv_EndDescriptorPoolUpdate(
VkDevice device,
VkCmdBuffer cmd)
{
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkCreateDescriptorPool(
+VkResult anv_CreateDescriptorPool(
VkDevice device,
VkDescriptorPoolUsage poolUsage,
uint32_t maxSets,
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkResetDescriptorPool(
+VkResult anv_ResetDescriptorPool(
VkDevice device,
VkDescriptorPool descriptorPool)
{
stub_return(VK_UNSUPPORTED);
}
-VkResult VKAPI vkAllocDescriptorSets(
+VkResult anv_AllocDescriptorSets(
VkDevice _device,
VkDescriptorPool descriptorPool,
VkDescriptorSetUsage setUsage,
return VK_UNSUPPORTED;
}
-void VKAPI vkClearDescriptorSets(
+void anv_ClearDescriptorSets(
VkDevice device,
VkDescriptorPool descriptorPool,
uint32_t count,
stub();
}
-void VKAPI vkUpdateDescriptors(
+void anv_UpdateDescriptors(
VkDevice _device,
VkDescriptorSet descriptorSet,
uint32_t updateCount,
return max;
}
-VkResult VKAPI vkCreateDynamicViewportState(
+VkResult anv_CreateDynamicViewportState(
VkDevice _device,
const VkDynamicVpStateCreateInfo* pCreateInfo,
VkDynamicVpState* pState)
return VK_SUCCESS;
}
-VkResult VKAPI vkCreateDynamicRasterState(
+VkResult anv_CreateDynamicRasterState(
VkDevice _device,
const VkDynamicRsStateCreateInfo* pCreateInfo,
VkDynamicRsState* pState)
return VK_SUCCESS;
}
-VkResult VKAPI vkCreateDynamicColorBlendState(
+VkResult anv_CreateDynamicColorBlendState(
VkDevice _device,
const VkDynamicCbStateCreateInfo* pCreateInfo,
VkDynamicCbState* pState)
return VK_SUCCESS;
}
-VkResult VKAPI vkCreateDynamicDepthStencilState(
+VkResult anv_CreateDynamicDepthStencilState(
VkDevice device,
const VkDynamicDsStateCreateInfo* pCreateInfo,
VkDynamicDsState* pState)
// Command buffer functions
-VkResult VKAPI vkCreateCommandBuffer(
+VkResult anv_CreateCommandBuffer(
VkDevice _device,
const VkCmdBufferCreateInfo* pCreateInfo,
VkCmdBuffer* pCmdBuffer)
return result;
}
-VkResult VKAPI vkBeginCommandBuffer(
+VkResult anv_BeginCommandBuffer(
VkCmdBuffer cmdBuffer,
const VkCmdBufferBeginInfo* pBeginInfo)
{
}
}
-VkResult VKAPI vkEndCommandBuffer(
+VkResult anv_EndCommandBuffer(
VkCmdBuffer cmdBuffer)
{
struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
return VK_SUCCESS;
}
-VkResult VKAPI vkResetCommandBuffer(
+VkResult anv_ResetCommandBuffer(
VkCmdBuffer cmdBuffer)
{
struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer;
// Command buffer building functions
-void VKAPI vkCmdBindPipeline(
+void anv_CmdBindPipeline(
VkCmdBuffer cmdBuffer,
VkPipelineBindPoint pipelineBindPoint,
VkPipeline _pipeline)
cmd_buffer->dirty |= ANV_CMD_BUFFER_PIPELINE_DIRTY;
}
-void VKAPI vkCmdBindDynamicStateObject(
+void anv_CmdBindDynamicStateObject(
VkCmdBuffer cmdBuffer,
VkStateBindPoint stateBindPoint,
VkDynamicStateObject dynamicState)
};
}
-void VKAPI vkCmdBindDescriptorSets(
+void anv_CmdBindDescriptorSets(
VkCmdBuffer cmdBuffer,
VkPipelineBindPoint pipelineBindPoint,
uint32_t firstSet,
cmd_buffer->dirty |= ANV_CMD_BUFFER_DESCRIPTOR_SET_DIRTY;
}
-void VKAPI vkCmdBindIndexBuffer(
+void anv_CmdBindIndexBuffer(
VkCmdBuffer cmdBuffer,
VkBuffer _buffer,
VkDeviceSize offset,
.BufferSize = buffer->size - offset);
}
-void VKAPI vkCmdBindVertexBuffers(
+void anv_CmdBindVertexBuffers(
VkCmdBuffer cmdBuffer,
uint32_t startBinding,
uint32_t bindingCount,
cmd_buffer->dirty = 0;
}
-void VKAPI vkCmdDraw(
+void anv_CmdDraw(
VkCmdBuffer cmdBuffer,
uint32_t firstVertex,
uint32_t vertexCount,
.BaseVertexLocation = 0);
}
-void VKAPI vkCmdDrawIndexed(
+void anv_CmdDrawIndexed(
VkCmdBuffer cmdBuffer,
uint32_t firstIndex,
uint32_t indexCount,
#define GEN7_3DPRIM_START_INSTANCE 0x243C
#define GEN7_3DPRIM_BASE_VERTEX 0x2440
-void VKAPI vkCmdDrawIndirect(
+void anv_CmdDrawIndirect(
VkCmdBuffer cmdBuffer,
VkBuffer _buffer,
VkDeviceSize offset,
.VertexAccessType = SEQUENTIAL);
}
-void VKAPI vkCmdDrawIndexedIndirect(
+void anv_CmdDrawIndexedIndirect(
VkCmdBuffer cmdBuffer,
VkBuffer _buffer,
VkDeviceSize offset,
.VertexAccessType = RANDOM);
}
-void VKAPI vkCmdDispatch(
+void anv_CmdDispatch(
VkCmdBuffer cmdBuffer,
uint32_t x,
uint32_t y,
stub();
}
-void VKAPI vkCmdDispatchIndirect(
+void anv_CmdDispatchIndirect(
VkCmdBuffer cmdBuffer,
VkBuffer buffer,
VkDeviceSize offset)
stub();
}
-void VKAPI vkCmdSetEvent(
+void anv_CmdSetEvent(
VkCmdBuffer cmdBuffer,
VkEvent event,
VkPipeEvent pipeEvent)
stub();
}
-void VKAPI vkCmdResetEvent(
+void anv_CmdResetEvent(
VkCmdBuffer cmdBuffer,
VkEvent event,
VkPipeEvent pipeEvent)
stub();
}
-void VKAPI vkCmdWaitEvents(
+void anv_CmdWaitEvents(
VkCmdBuffer cmdBuffer,
VkWaitEvent waitEvent,
uint32_t eventCount,
stub();
}
-void VKAPI vkCmdPipelineBarrier(
+void anv_CmdPipelineBarrier(
VkCmdBuffer cmdBuffer,
VkWaitEvent waitEvent,
uint32_t pipeEventCount,
.Address = { bo, offset }); /* FIXME: This is only lower 32 bits */
}
-void VKAPI vkCmdBeginQuery(
+void anv_CmdBeginQuery(
VkCmdBuffer cmdBuffer,
VkQueryPool queryPool,
uint32_t slot,
}
}
-void VKAPI vkCmdEndQuery(
+void anv_CmdEndQuery(
VkCmdBuffer cmdBuffer,
VkQueryPool queryPool,
uint32_t slot)
}
}
-void VKAPI vkCmdResetQueryPool(
+void anv_CmdResetQueryPool(
VkCmdBuffer cmdBuffer,
VkQueryPool queryPool,
uint32_t startQuery,
#define TIMESTAMP 0x44070
-void VKAPI vkCmdWriteTimestamp(
+void anv_CmdWriteTimestamp(
VkCmdBuffer cmdBuffer,
VkTimestampType timestampType,
VkBuffer destBuffer,
}
}
-void VKAPI vkCmdCopyQueryPoolResults(
+void anv_CmdCopyQueryPoolResults(
VkCmdBuffer cmdBuffer,
VkQueryPool queryPool,
uint32_t startQuery,
stub();
}
-void VKAPI vkCmdInitAtomicCounters(
+void anv_CmdInitAtomicCounters(
VkCmdBuffer cmdBuffer,
VkPipelineBindPoint pipelineBindPoint,
uint32_t startCounter,
stub();
}
-void VKAPI vkCmdLoadAtomicCounters(
+void anv_CmdLoadAtomicCounters(
VkCmdBuffer cmdBuffer,
VkPipelineBindPoint pipelineBindPoint,
uint32_t startCounter,
stub();
}
-void VKAPI vkCmdSaveAtomicCounters(
+void anv_CmdSaveAtomicCounters(
VkCmdBuffer cmdBuffer,
VkPipelineBindPoint pipelineBindPoint,
uint32_t startCounter,
stub();
}
-VkResult VKAPI vkCreateFramebuffer(
+VkResult anv_CreateFramebuffer(
VkDevice _device,
const VkFramebufferCreateInfo* pCreateInfo,
VkFramebuffer* pFramebuffer)
return VK_SUCCESS;
}
-VkResult VKAPI vkCreateRenderPass(
+VkResult anv_CreateRenderPass(
VkDevice _device,
const VkRenderPassCreateInfo* pCreateInfo,
VkRenderPass* pRenderPass)
cmd_buffer->dirty |= ANV_CMD_BUFFER_DESCRIPTOR_SET_DIRTY;
}
-void VKAPI vkCmdBeginRenderPass(
+void anv_CmdBeginRenderPass(
VkCmdBuffer cmdBuffer,
const VkRenderPassBegin* pRenderPassBegin)
{
anv_cmd_buffer_clear(cmd_buffer, pass);
}
-void VKAPI vkCmdEndRenderPass(
+void anv_CmdEndRenderPass(
VkCmdBuffer cmdBuffer,
VkRenderPass renderPass)
{
--- /dev/null
+# coding=utf-8
+#
+# Copyright © 2015 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# 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.
+#
+
+import fileinput, re, sys
+
+# Each function typedef in the vulkan.h header is all on one line and matches
+# this regepx. We hope that won't change.
+
+p = re.compile('typedef ([^ ]*) *\(VKAPI \*PFN_vk([^(]*)\)(.*);')
+
+entrypoints = []
+
+# We generate a static hash table for entry point lookup
+# (vkGetProcAddress). We use a linear congruential generator for our hash
+# function and a power-of-two size table. The prime numbers are determined
+# experimentally.
+
+none = 0xffff
+hash_size = 256
+u32_mask = 2**32 - 1
+hash_mask = hash_size - 1
+
+prime_factor = 5024183
+prime_step = 19
+
+def hash(name):
+ h = 0;
+ for c in name:
+ h = (h * prime_factor + ord(c)) & u32_mask
+
+ return h
+
+opt_header = False
+opt_code = False
+
+if (sys.argv[1] == "header"):
+ opt_header = True
+ sys.argv.pop()
+elif (sys.argv[1] == "code"):
+ opt_code = True
+ sys.argv.pop()
+
+# Parse the entry points in the header
+
+i = 0
+for line in fileinput.input():
+ m = p.match(line)
+ if (m):
+ fullname = "vk" + m.group(2)
+ h = hash(fullname)
+ entrypoints.append((m.group(1), m.group(2), m.group(3), i, h))
+ i = i + 1
+
+# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
+# per entry point.
+
+if opt_header:
+ for type, name, args, num, h in entrypoints:
+ print "%s anv_%s%s;" % (type, name, args)
+ print "%s anv_validate_%s%s;" % (type, name, args)
+ exit()
+
+
+
+print """/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * 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.
+ */
+
+/* This file generated from vk_gen.py, don't edit directly. */
+
+#include "private.h"
+
+struct anv_entrypoint {
+ uint32_t name;
+ uint32_t hash;
+ void *function;
+ void *validate;
+};
+
+/* We use a big string constant to avoid lots of reloctions from the entry
+ * point table to lots of little strings. The entries in the entry point table
+ * store the index into this big string.
+ */
+
+static const char strings[] ="""
+
+offsets = []
+i = 0;
+for type, name, args, num, h in entrypoints:
+ print " \"vk%s\\0\"" % name
+ offsets.append(i)
+ i += 2 + len(name) + 1
+print """ ;
+
+/* Weak aliases for all potential validate functions. These will resolve to
+ * NULL if they're not defined, which lets the resolve_entrypoint() function
+ * either pick a validate wrapper if available or just plug in the actual
+ * entry point.
+ */
+"""
+
+for type, name, args, num, h in entrypoints:
+ print "%s anv_validate_%s%s __attribute__ ((weak));" % (type, name, args)
+
+# Now generate the table of all entry points and their validation functions
+
+print "\nstatic const struct anv_entrypoint entrypoints[] = {"
+for type, name, args, num, h in entrypoints:
+ print " { %5d, 0x%08x, anv_%s, anv_validate_%s }," % (offsets[num], h, name, name)
+print "};\n"
+
+print """
+#ifdef DEBUG
+static bool enable_validate = true;
+#else
+static bool enable_validate = false;
+#endif
+
+/* We can't use symbols that need resolving (like, oh, getenv) in the resolve
+ * function. This means that we have to determine whether or not to use the
+ * validation layer sometime before that. The constructor function attribute asks
+ * the dynamic linker to invoke determine_validate() at dlopen() time which
+ * works.
+ */
+static void __attribute__ ((constructor))
+determine_validate(void)
+{
+ const char *s = getenv("ANV_VALIDATE");
+
+ if (s)
+ enable_validate = atoi(s);
+}
+
+static void * __attribute__ ((noinline))
+resolve_entrypoint(uint32_t index)
+{
+ if (enable_validate && entrypoints[index].validate)
+ return entrypoints[index].validate;
+
+ return entrypoints[index].function;
+}
+"""
+
+# Now output ifuncs and their resolve helpers for all entry points. The
+# resolve helper calls resolve_entrypoint() with the entry point index, which
+# lets the resolver look it up in the table.
+
+for type, name, args, num, h in entrypoints:
+ print "static void *resolve_%s(void) { return resolve_entrypoint(%d); }" % (name, num)
+ print "%s vk%s%s\n __attribute__ ((ifunc (\"resolve_%s\"), visibility (\"default\")));\n" % (type, name, args, name)
+
+# Now generate the hash table used for entry point look up. This is a
+# uint16_t table of entry point indices. We use 0xffff to indicate an entry
+# in the hash table is empty.
+
+map = [none for f in xrange(hash_size)]
+collisions = [0 for f in xrange(10)]
+for type, name, args, num, h in entrypoints:
+ level = 0
+ while map[h & hash_mask] != none:
+ h = h + prime_step
+ level = level + 1
+ if level > 9:
+ collisions[9] += 1
+ else:
+ collisions[level] += 1
+ map[h & hash_mask] = num
+
+print "/* Hash table stats:"
+print " * size %d entries" % hash_size
+print " * collisions entries"
+for i in xrange(10):
+ if (i == 9):
+ plus = "+"
+ else:
+ plus = " "
+
+ print " * %2d%s %4d" % (i, plus, collisions[i])
+print " */\n"
+
+print "#define none 0x%04x\n" % none
+
+print "static const uint16_t map[] = {"
+for i in xrange(0, hash_size, 8):
+ print " ",
+ for j in xrange(i, i + 8):
+ if map[j] & 0xffff == 0xffff:
+ print " none,",
+ else:
+ print "0x%04x," % (map[j] & 0xffff),
+ print
+
+print "};"
+
+# Finally we generate the hash table lookup function. The hash function and
+# linear probing algorithm matches the hash table generated above.
+
+print """
+void *
+anv_lookup_entrypoint(const char *name)
+{
+ static const uint32_t prime_factor = %d;
+ static const uint32_t prime_step = %d;
+ const struct anv_entrypoint *e;
+ uint32_t hash, h, i;
+ const char *p;
+
+ hash = 0;
+ for (p = name; *p; p++)
+ hash = hash * prime_factor + *p;
+
+ h = hash;
+ do {
+ i = map[h & %d];
+ if (i == none)
+ return NULL;
+ e = &entrypoints[i];
+ h += prime_step;
+ } while (e->hash != hash);
+
+ if (strcmp(name, strings + e->name) != 0)
+ return NULL;
+
+ return resolve_entrypoint(i);
+}
+""" % (prime_factor, prime_step, hash_mask)