At this commit test fails at libresoc_GetDeviceQueue() which is yet to be implemented.
--- /dev/null
+/*
+ * Copyright © 2017 Google.
+ *
+ * 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.
+ */
+
+#ifndef LIBRESOC_DEBUG_H
+#define LIBRESOC_DEBUG_H
+
+#include "libresoc_private.h"
+
+/* Please keep docs/envvars.rst up-to-date when you add/remove options. */
+enum {
+ LIBRESOC_DEBUG_NO_FAST_CLEARS = 1 << 0,
+ LIBRESOC_DEBUG_NO_DCC = 1 << 1,
+ LIBRESOC_DEBUG_DUMP_SHADERS = 1 << 2,
+ LIBRESOC_DEBUG_NO_CACHE = 1 << 3,
+ LIBRESOC_DEBUG_DUMP_SHADER_STATS = 1 << 4,
+ LIBRESOC_DEBUG_NO_HIZ = 1 << 5,
+ LIBRESOC_DEBUG_NO_COMPUTE_QUEUE = 1 << 6,
+ LIBRESOC_DEBUG_ALL_BOS = 1 << 7,
+ LIBRESOC_DEBUG_NO_IBS = 1 << 8,
+ LIBRESOC_DEBUG_DUMP_SPIRV = 1 << 9,
+ LIBRESOC_DEBUG_VM_FAULTS = 1 << 10,
+ LIBRESOC_DEBUG_ZERO_VRAM = 1 << 11,
+ LIBRESOC_DEBUG_SYNC_SHADERS = 1 << 12,
+ LIBRESOC_DEBUG_PREOPTIR = 1 << 13,
+ LIBRESOC_DEBUG_NO_DYNAMIC_BOUNDS = 1 << 14,
+ LIBRESOC_DEBUG_NO_OUT_OF_ORDER = 1 << 15,
+ LIBRESOC_DEBUG_INFO = 1 << 16,
+ LIBRESOC_DEBUG_ERRORS = 1 << 17,
+ LIBRESOC_DEBUG_STARTUP = 1 << 18,
+ LIBRESOC_DEBUG_CHECKIR = 1 << 19,
+ LIBRESOC_DEBUG_NOTHREADLLVM = 1 << 20,
+ LIBRESOC_DEBUG_NOBINNING = 1 << 21,
+ LIBRESOC_DEBUG_NO_NGG = 1 << 22,
+ LIBRESOC_DEBUG_ALL_ENTRYPOINTS = 1 << 23,
+ LIBRESOC_DEBUG_DUMP_META_SHADERS = 1 << 24,
+ LIBRESOC_DEBUG_NO_MEMORY_CACHE = 1 << 25,
+ LIBRESOC_DEBUG_DISCARD_TO_DEMOTE = 1 << 26,
+ LIBRESOC_DEBUG_LLVM = 1 << 27,
+ LIBRESOC_DEBUG_FORCE_COMPRESS = 1 << 28,
+};
+
+enum {
+ LIBRESOC_PERFTEST_LOCAL_BOS = 1 << 0,
+ LIBRESOC_PERFTEST_DCC_MSAA = 1 << 1,
+ LIBRESOC_PERFTEST_BO_LIST = 1 << 2,
+ LIBRESOC_PERFTEST_TC_COMPAT_CMASK = 1 << 3,
+ LIBRESOC_PERFTEST_CS_WAVE_32 = 1 << 4,
+ LIBRESOC_PERFTEST_PS_WAVE_32 = 1 << 5,
+ LIBRESOC_PERFTEST_GE_WAVE_32 = 1 << 6,
+ LIBRESOC_PERFTEST_DFSM = 1 << 7,
+};
+
+bool
+libresoc_init_trace(struct libresoc_device *device);
+
+void
+libresoc_print_spirv(const char *data, uint32_t size, FILE *fp);
+
+void
+libresoc_dump_enabled_options(struct libresoc_device *device, FILE *f);
+
+#endif
#include <sys/sysinfo.h>
#include <unistd.h>
+#include "util/debug.h"
#include "libresoc_private.h"
#include "vk_util.h"
#include "vk_alloc.h"
.pfnFree = default_free_func,
};
+static const struct debug_control libresoc_debug_options[] = {
+ {"nofastclears", LIBRESOC_DEBUG_NO_FAST_CLEARS},
+ {"nodcc", LIBRESOC_DEBUG_NO_DCC},
+ {"shaders", LIBRESOC_DEBUG_DUMP_SHADERS},
+ {"nocache", LIBRESOC_DEBUG_NO_CACHE},
+ {"shaderstats", LIBRESOC_DEBUG_DUMP_SHADER_STATS},
+ {"nohiz", LIBRESOC_DEBUG_NO_HIZ},
+ {"nocompute", LIBRESOC_DEBUG_NO_COMPUTE_QUEUE},
+ {"allbos", LIBRESOC_DEBUG_ALL_BOS},
+ {"noibs", LIBRESOC_DEBUG_NO_IBS},
+ {"spirv", LIBRESOC_DEBUG_DUMP_SPIRV},
+ {"vmfaults", LIBRESOC_DEBUG_VM_FAULTS},
+ {"zerovram", LIBRESOC_DEBUG_ZERO_VRAM},
+ {"syncshaders", LIBRESOC_DEBUG_SYNC_SHADERS},
+ {"preoptir", LIBRESOC_DEBUG_PREOPTIR},
+ {"nodynamicbounds", LIBRESOC_DEBUG_NO_DYNAMIC_BOUNDS},
+ {"nooutoforder", LIBRESOC_DEBUG_NO_OUT_OF_ORDER},
+ {"info", LIBRESOC_DEBUG_INFO},
+ {"errors", LIBRESOC_DEBUG_ERRORS},
+ {"startup", LIBRESOC_DEBUG_STARTUP},
+ {"checkir", LIBRESOC_DEBUG_CHECKIR},
+ {"nothreadllvm", LIBRESOC_DEBUG_NOTHREADLLVM},
+ {"nobinning", LIBRESOC_DEBUG_NOBINNING},
+ {"nongg", LIBRESOC_DEBUG_NO_NGG},
+ {"allentrypoints", LIBRESOC_DEBUG_ALL_ENTRYPOINTS},
+ {"metashaders", LIBRESOC_DEBUG_DUMP_META_SHADERS},
+ {"nomemorycache", LIBRESOC_DEBUG_NO_MEMORY_CACHE},
+ {"llvm", LIBRESOC_DEBUG_LLVM},
+ {"forcecompress", LIBRESOC_DEBUG_FORCE_COMPRESS},
+ {NULL, 0}
+};
+
+const char *
+libresoc_get_debug_option_name(int id)
+{
+ assert(id < ARRAY_SIZE(libresoc_debug_options) - 1);
+ return libresoc_debug_options[id].string;
+}
VkResult
libresoc_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
instance->engineVersion = app->engineVersion;
instance->apiVersion = app->apiVersion;
}
+ instance->debug_flags = parse_debug_string(getenv("LIBRESOC_DEBUG"),
+ libresoc_debug_options);
/*TODO : enable extensions*/
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
int idx;
*pProperties = (VkPhysicalDeviceProperties) {
.apiVersion = libresoc_physical_device_api_version(pdevice),
.driverVersion = vk_get_driver_version(),
- .vendorID = 1,
- .deviceID = 1,
+ .vendorID = 1, //TODO: some dummy value
+ .deviceID = 1, //TODO: dome dummay value
.deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
.limits = limits,
.sparseProperties = {0},
};
strcpy(pProperties->deviceName, pdevice->name);
-// memcpy(pProperties->pipelineCacheUUID, pdevice->cache_uuid, VK_UUID_SIZE);
+ memcpy(pProperties->pipelineCacheUUID, pdevice->cache_uuid, VK_UUID_SIZE);
}
static void libresoc_get_physical_device_queue_family_properties(
#include <vulkan/vulkan.h>
#include <vulkan/vk_icd.h>
+#include "vk_alloc.h"
#include "vk_debug_report.h"
#include "util/xmlconfig.h"
+#include "compiler/shader_enums.h"
#include "vk_object.h"
#include "libresoc_entrypoints.h"
#include "libresoc_extensions.h"
#include "libresoc_constants.h"
+#include "libresoc_debug.h"
#define LIBRESOC_MAX_QUEUE_FAMILIES 1
struct libresoc_instance;
+struct libresoc_device;
+struct cache_entry;
+
+struct libresoc_pipeline_cache {
+ struct vk_object_base base;
+ struct libresoc_device * device;
+ pthread_mutex_t mutex;
+ VkPipelineCacheCreateFlags flags;
+
+ uint32_t total_size;
+ uint32_t table_size;
+ uint32_t kernel_count;
+ struct cache_entry ** hash_table;
+ bool modified;
+
+ VkAllocationCallbacks alloc;
+};
+
+
+struct libresoc_shader_binary;
+struct libresoc_shader_variant;
+void
+libresoc_pipeline_cache_init(struct libresoc_pipeline_cache *cache,
+ struct libresoc_device *device);
+void
+libresoc_pipeline_cache_finish(struct libresoc_pipeline_cache *cache);
+bool
+libresoc_pipeline_cache_load(struct libresoc_pipeline_cache *cache,
+ const void *data, size_t size);
+
+bool
+libresoc_create_shader_variants_from_pipeline_cache(struct libresoc_device *device,
+ struct libresoc_pipeline_cache *cache,
+ const unsigned char *sha1,
+ struct libresoc_shader_variant **variants,
+ bool *found_in_application_cache);
+
+void
+libresoc_pipeline_cache_insert_shaders(struct libresoc_device *device,
+ struct libresoc_pipeline_cache *cache,
+ const unsigned char *sha1,
+ struct libresoc_shader_variant **variants,
+ struct libresoc_shader_binary *const *binaries);
struct libresoc_device {
- VK_LOADER_DATA _loader_data;
struct vk_device vk;
VkAllocationCallbacks alloc;
struct radeon_cmdbuf *empty_cs[LIBRESOC_MAX_QUEUE_FAMILIES];
struct libresoc_physical_device *physical_device;
+ /* Backup in-memory cache to be used if the app doesn't provide one */
+ struct libresoc_pipeline_cache * mem_cache;
/* FIXME: stub */
};
struct libresoc_physical_device_dispatch_table dispatch;
char name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE];
+ uint8_t driver_uuid[VK_UUID_SIZE];
+ uint8_t device_uuid[VK_UUID_SIZE];
+ uint8_t cache_uuid[VK_UUID_SIZE];
/* FIXME: stub */
};
struct libresoc_instance {
struct vk_object_base base;
- VK_LOADER_DATA _loader_data;
VkAllocationCallbacks alloc;
uint32_t apiVersion;
+ uint64_t debug_flags;
char * engineName;
uint32_t engineVersion;
struct libresoc_app_info app_info;
};
struct libresoc_cmd_buffer {
- VK_LOADER_DATA _loader_data;
struct libresoc_device *device;
void *libresoc_lookup_entrypoint(const char *name);
+const char *
+libresoc_get_debug_option_name(int id);
+
#define libresoc_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
VkResult __vk_errorf(struct libresoc_instance *instance, VkResult error,
return (__VkType) _obj; \
}
+#define LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(__libresoc_type, __VkType) \
+ \
+ static inline struct __libresoc_type * \
+ __libresoc_type ## _from_handle(__VkType _handle) \
+ { \
+ return (struct __libresoc_type *)(uintptr_t) _handle; \
+ } \
+ \
+ static inline __VkType \
+ __libresoc_type ## _to_handle(struct __libresoc_type *_obj) \
+ { \
+ return (__VkType)(uintptr_t) _obj; \
+ }
+
#define LIBRESOC_FROM_HANDLE(__libresoc_type, __name, __handle) \
struct __libresoc_type *__name = __libresoc_type ## _from_handle(__handle)
LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_physical_device, VkPhysicalDevice)
LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_queue, VkQueue)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_cmd_pool, VkCommandPool)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_buffer, VkBuffer)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_buffer_view, VkBufferView)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_descriptor_pool, VkDescriptorPool)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_descriptor_set, VkDescriptorSet)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_descriptor_set_layout, VkDescriptorSetLayout)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_descriptor_update_template, VkDescriptorUpdateTemplate)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_device_memory, VkDeviceMemory)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_fence, VkFence)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_event, VkEvent)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_framebuffer, VkFramebuffer)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_image, VkImage)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_image_view, VkImageView);
+LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_pipeline_cache, VkPipelineCache)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_pipeline, VkPipeline)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_pipeline_layout, VkPipelineLayout)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_query_pool, VkQueryPool)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_render_pass, VkRenderPass)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_sampler, VkSampler)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_sampler_ycbcr_conversion, VkSamplerYcbcrConversion)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_shader_module, VkShaderModule)
+//LIBRESOC_DEFINE_NONDISP_HANDLE_CASTS(libresoc_semaphore, VkSemaphore)
#endif /* LIBRESOC_PRIVATE_H */
liblibresoc_files = files(
'libresoc_device.c',
'libresoc_pipeline.c',
+ 'libresoc_pipeline_cache.c',
'libresoc_util.c',
)