Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions VulkanFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,10 @@ typedef void(VKAPI_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer commandBuffer,
VkQueryPool queryPool, uint32_t query);

struct VulkanDevice {
VkInstance instance;
VkPhysicalDevice physical_device;
VkDevice device;
VkInstance instance = {};
VkPhysicalDevice physical_device = {};
VkDevice device = {};
VkPipelineCache pipeline_cache = {};
};
struct VulkanFunctions {
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
Expand Down
1 change: 1 addition & 0 deletions internal/Vk/ContextVK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ bool Ray::Vk::Context::Init(ILog *log, const VulkanDevice &vk_device, const Vulk
instance_ = vk_device.instance;
physical_device_ = vk_device.physical_device;
device_ = vk_device.device;
pipeline_cache_ = vk_device.pipeline_cache;
static_cast<VulkanFunctions &>(api_) = vk_functions;

external_ = (instance_ != VK_NULL_HANDLE);
Expand Down
2 changes: 2 additions & 0 deletions internal/Vk/ContextVK.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Context {
uint32_t graphics_family_index_ = 0;

VkDevice device_ = {};
VkPipelineCache pipeline_cache_ = {};

bool raytracing_supported_ = false, ray_query_supported_ = false;
VkPhysicalDeviceRayTracingPipelinePropertiesKHR rt_props_ = {
Expand Down Expand Up @@ -79,6 +80,7 @@ class Context {

VkDevice device() const { return device_; }
VkPhysicalDevice physical_device() const { return physical_device_; }
VkPipelineCache pipeline_cache() const { return pipeline_cache_; }

ILog *log() const { return log_; }
const Api &api() const { return api_; }
Expand Down
8 changes: 4 additions & 4 deletions internal/Vk/PipelineVK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ bool Ray::Vk::Pipeline::Init(Context *ctx, const RastState &rast_state, Program
pipeline_create_info.pNext = &pipeline_rendering_create_info;
}

const VkResult res = ctx->api().vkCreateGraphicsPipelines(ctx->device(), VK_NULL_HANDLE, 1,
const VkResult res = ctx->api().vkCreateGraphicsPipelines(ctx->device(), ctx->pipeline_cache(), 1,
&pipeline_create_info, nullptr, &handle_);
if (res != VK_SUCCESS) {
log->Error("Failed to create graphics pipeline!");
Expand Down Expand Up @@ -445,7 +445,7 @@ bool Ray::Vk::Pipeline::Init(Context *ctx, Program *prog, ILog *log) {
info.layout = layout_;

const VkResult res =
ctx->api().vkCreateComputePipelines(ctx->device(), VK_NULL_HANDLE, 1, &info, nullptr, &handle_);
ctx->api().vkCreateComputePipelines(ctx->device(), ctx->pipeline_cache(), 1, &info, nullptr, &handle_);
if (res != VK_SUCCESS) {
log->Error("Failed to create pipeline!");
return false;
Expand All @@ -459,8 +459,8 @@ bool Ray::Vk::Pipeline::Init(Context *ctx, Program *prog, ILog *log) {
info.groupCount = rt_shader_groups_.size();
info.pGroups = rt_shader_groups_.cdata();

const VkResult res = ctx->api().vkCreateRayTracingPipelinesKHR(ctx->device(), VK_NULL_HANDLE, VK_NULL_HANDLE, 1,
&info, nullptr, &handle_);
const VkResult res = ctx->api().vkCreateRayTracingPipelinesKHR(
ctx->device(), VK_NULL_HANDLE, ctx->pipeline_cache(), 1, &info, nullptr, &handle_);
if (res != VK_SUCCESS) {
log->Error("Failed to create pipeline!");
return false;
Expand Down