PipelineCache::ConfigurePipeline - Inform the caller if the pipeline is dirty or they can reuse the previously bound pipeline.
Make SetDynamicState public.
This commit is contained in:
parent
b2457d7e72
commit
1e1da1eb6c
|
@ -183,11 +183,12 @@ VulkanShader* PipelineCache::LoadShader(ShaderType shader_type,
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PipelineCache::ConfigurePipeline(VkCommandBuffer command_buffer,
|
PipelineCache::UpdateStatus PipelineCache::ConfigurePipeline(
|
||||||
const RenderState* render_state,
|
VkCommandBuffer command_buffer, const RenderState* render_state,
|
||||||
VulkanShader* vertex_shader,
|
VulkanShader* vertex_shader, VulkanShader* pixel_shader,
|
||||||
VulkanShader* pixel_shader,
|
PrimitiveType primitive_type, VkPipeline* pipeline_out) {
|
||||||
PrimitiveType primitive_type) {
|
assert_not_null(pipeline_out);
|
||||||
|
|
||||||
// Perform a pass over all registers and state updating our cached structures.
|
// Perform a pass over all registers and state updating our cached structures.
|
||||||
// This will tell us if anything has changed that requires us to either build
|
// This will tell us if anything has changed that requires us to either build
|
||||||
// a new pipeline or use an existing one.
|
// a new pipeline or use an existing one.
|
||||||
|
@ -208,7 +209,7 @@ bool PipelineCache::ConfigurePipeline(VkCommandBuffer command_buffer,
|
||||||
// Error updating state - bail out.
|
// Error updating state - bail out.
|
||||||
// We are in an indeterminate state, so reset things for the next attempt.
|
// We are in an indeterminate state, so reset things for the next attempt.
|
||||||
current_pipeline_ = nullptr;
|
current_pipeline_ = nullptr;
|
||||||
return false;
|
return update_status;
|
||||||
}
|
}
|
||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
// Should have a hash key produced by the UpdateState pass.
|
// Should have a hash key produced by the UpdateState pass.
|
||||||
|
@ -217,24 +218,12 @@ bool PipelineCache::ConfigurePipeline(VkCommandBuffer command_buffer,
|
||||||
current_pipeline_ = pipeline;
|
current_pipeline_ = pipeline;
|
||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
// Unable to create pipeline.
|
// Unable to create pipeline.
|
||||||
return false;
|
return UpdateStatus::kError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind the pipeline.
|
*pipeline_out = pipeline;
|
||||||
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
return update_status;
|
||||||
|
|
||||||
// Issue all changed dynamic state information commands.
|
|
||||||
// TODO(benvanik): dynamic state is kept in the command buffer, so if we
|
|
||||||
// have issued it before (regardless of pipeline) we don't need to do it now.
|
|
||||||
// TODO(benvanik): track whether we have issued on the given command buffer.
|
|
||||||
bool full_dynamic_state = true;
|
|
||||||
if (!SetDynamicState(command_buffer, full_dynamic_state)) {
|
|
||||||
// Failed to update state.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PipelineCache::ClearCache() {
|
void PipelineCache::ClearCache() {
|
||||||
|
|
|
@ -32,6 +32,12 @@ namespace vulkan {
|
||||||
// including shaders, various blend/etc options, and input configuration.
|
// including shaders, various blend/etc options, and input configuration.
|
||||||
class PipelineCache {
|
class PipelineCache {
|
||||||
public:
|
public:
|
||||||
|
enum class UpdateStatus {
|
||||||
|
kCompatible,
|
||||||
|
kMismatch,
|
||||||
|
kError,
|
||||||
|
};
|
||||||
|
|
||||||
PipelineCache(RegisterFile* register_file, ui::vulkan::VulkanDevice* device,
|
PipelineCache(RegisterFile* register_file, ui::vulkan::VulkanDevice* device,
|
||||||
VkDescriptorSetLayout uniform_descriptor_set_layout,
|
VkDescriptorSetLayout uniform_descriptor_set_layout,
|
||||||
VkDescriptorSetLayout texture_descriptor_set_layout);
|
VkDescriptorSetLayout texture_descriptor_set_layout);
|
||||||
|
@ -46,11 +52,17 @@ class PipelineCache {
|
||||||
// otherwise a new one may be created. Any state that can be set dynamically
|
// otherwise a new one may be created. Any state that can be set dynamically
|
||||||
// in the command buffer is issued at this time.
|
// in the command buffer is issued at this time.
|
||||||
// Returns whether the pipeline could be successfully created.
|
// Returns whether the pipeline could be successfully created.
|
||||||
bool ConfigurePipeline(VkCommandBuffer command_buffer,
|
UpdateStatus ConfigurePipeline(VkCommandBuffer command_buffer,
|
||||||
const RenderState* render_state,
|
const RenderState* render_state,
|
||||||
VulkanShader* vertex_shader,
|
VulkanShader* vertex_shader,
|
||||||
VulkanShader* pixel_shader,
|
VulkanShader* pixel_shader,
|
||||||
PrimitiveType primitive_type);
|
PrimitiveType primitive_type,
|
||||||
|
VkPipeline* pipeline_out);
|
||||||
|
|
||||||
|
// Sets required dynamic state on the command buffer.
|
||||||
|
// Only state that has changed since the last call will be set unless
|
||||||
|
// full_update is true.
|
||||||
|
bool SetDynamicState(VkCommandBuffer command_buffer, bool full_update);
|
||||||
|
|
||||||
// Pipeline layout shared by all pipelines.
|
// Pipeline layout shared by all pipelines.
|
||||||
VkPipelineLayout pipeline_layout() const { return pipeline_layout_; }
|
VkPipelineLayout pipeline_layout() const { return pipeline_layout_; }
|
||||||
|
@ -68,11 +80,6 @@ class PipelineCache {
|
||||||
VkShaderModule GetGeometryShader(PrimitiveType primitive_type,
|
VkShaderModule GetGeometryShader(PrimitiveType primitive_type,
|
||||||
bool is_line_mode);
|
bool is_line_mode);
|
||||||
|
|
||||||
// Sets required dynamic state on the command buffer.
|
|
||||||
// Only state that has changed since the last call will be set unless
|
|
||||||
// full_update is true.
|
|
||||||
bool SetDynamicState(VkCommandBuffer command_buffer, bool full_update);
|
|
||||||
|
|
||||||
RegisterFile* register_file_ = nullptr;
|
RegisterFile* register_file_ = nullptr;
|
||||||
VkDevice device_ = nullptr;
|
VkDevice device_ = nullptr;
|
||||||
|
|
||||||
|
@ -111,12 +118,6 @@ class PipelineCache {
|
||||||
VkPipeline current_pipeline_ = nullptr;
|
VkPipeline current_pipeline_ = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class UpdateStatus {
|
|
||||||
kCompatible,
|
|
||||||
kMismatch,
|
|
||||||
kError,
|
|
||||||
};
|
|
||||||
|
|
||||||
UpdateStatus UpdateState(VulkanShader* vertex_shader,
|
UpdateStatus UpdateState(VulkanShader* vertex_shader,
|
||||||
VulkanShader* pixel_shader,
|
VulkanShader* pixel_shader,
|
||||||
PrimitiveType primitive_type);
|
PrimitiveType primitive_type);
|
||||||
|
|
Loading…
Reference in New Issue