WIP: Vulkan: Initial Immediate Mode Support. #106954
|
@ -24,7 +24,7 @@ void VKBatch::draw(int v_first, int v_count, int i_first, int i_count)
|
|||
VKContext &context = *VKContext::get();
|
||||
VKVertexAttributeObject &vao = vao_cache_.vao_get(this);
|
||||
vao.update_bindings(context, *this);
|
||||
context.bind_graphics_pipeline();
|
||||
context.bind_graphics_pipeline(vao);
|
||||
vao.bind(context);
|
||||
|
||||
VKIndexBuffer *index_buffer = index_buffer_get();
|
||||
|
|
|
@ -181,12 +181,14 @@ void VKContext::deactivate_framebuffer()
|
|||
/* -------------------------------------------------------------------- */
|
||||
/** \name Graphics pipeline
|
||||
* \{ */
|
||||
void VKContext::bind_graphics_pipeline()
|
||||
|
||||
void VKContext::bind_graphics_pipeline(const VKVertexAttributeObject &vertex_attribute_object)
|
||||
{
|
||||
VKShader *shader = unwrap(this->shader);
|
||||
BLI_assert(shader);
|
||||
shader->update_graphics_pipeline(*this);
|
||||
shader->update_graphics_pipeline(*this, vertex_attribute_object);
|
||||
command_buffer_get().bind(shader->pipeline_get(), VK_PIPELINE_BIND_POINT_GRAPHICS);
|
||||
shader->pipeline_get().push_constants_get().update(*this);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace blender::gpu {
|
||||
class VKFrameBuffer;
|
||||
class VKVertexAttributeObject;
|
||||
|
||||
class VKContext : public Context {
|
||||
private:
|
||||
|
@ -61,7 +62,7 @@ class VKContext : public Context {
|
|||
void deactivate_framebuffer();
|
||||
VKFrameBuffer *active_framebuffer_get() const;
|
||||
|
||||
void bind_graphics_pipeline();
|
||||
void bind_graphics_pipeline(const VKVertexAttributeObject &vertex_attribute_object);
|
||||
|
||||
static VKContext *get(void)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "vk_context.hh"
|
||||
#include "vk_framebuffer.hh"
|
||||
#include "vk_memory.hh"
|
||||
#include "vk_vertex_attribute_object.hh"
|
||||
|
||||
namespace blender::gpu {
|
||||
|
||||
|
@ -90,7 +91,8 @@ bool VKPipeline::is_valid() const
|
|||
void VKPipeline::finalize(VKContext &context,
|
||||
VkShaderModule vertex_module,
|
||||
VkShaderModule fragment_module,
|
||||
VkPipelineLayout &pipeline_layout)
|
||||
VkPipelineLayout &pipeline_layout,
|
||||
const VKVertexAttributeObject &vertex_attribute_object)
|
||||
{
|
||||
BLI_assert(vertex_module != VK_NULL_HANDLE);
|
||||
|
||||
|
@ -135,21 +137,10 @@ void VKPipeline::finalize(VKContext &context,
|
|||
VkPipelineVertexInputStateCreateInfo vertex_input_state = {};
|
||||
vertex_input_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||
vertex_input_state.vertexBindingDescriptionCount = 0;
|
||||
/* Dummy attribute containing the vertex positions. These should be extracted from shader create
|
||||
* infos. */
|
||||
VkVertexInputBindingDescription binding_description = {};
|
||||
binding_description.binding = 0;
|
||||
binding_description.stride = 4 * 3;
|
||||
binding_description.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||
vertex_input_state.vertexBindingDescriptionCount = 1;
|
||||
vertex_input_state.pVertexBindingDescriptions = &binding_description;
|
||||
VkVertexInputAttributeDescription attribute_description = {};
|
||||
attribute_description.location = 0;
|
||||
attribute_description.binding = 0;
|
||||
attribute_description.format = VK_FORMAT_R32G32B32_SFLOAT;
|
||||
attribute_description.offset = 0;
|
||||
vertex_input_state.vertexAttributeDescriptionCount = 1;
|
||||
vertex_input_state.pVertexAttributeDescriptions = &attribute_description;
|
||||
vertex_input_state.vertexBindingDescriptionCount = 1;//vertex_attribute_object.bindings.size();
|
||||
vertex_input_state.pVertexBindingDescriptions = vertex_attribute_object.bindings.data();
|
||||
vertex_input_state.vertexAttributeDescriptionCount = 1;//vertex_attribute_object.attributes.size();
|
||||
vertex_input_state.pVertexAttributeDescriptions = vertex_attribute_object.attributes.data();
|
||||
pipeline_create_info.pVertexInputState = &vertex_input_state;
|
||||
|
||||
/* Input assembly state. */
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
namespace blender::gpu {
|
||||
class VKContext;
|
||||
class VKShader;
|
||||
class VKVertexAttributeObject;
|
||||
|
||||
/**
|
||||
* Pipeline can be a compute pipeline or a graphic pipeline.
|
||||
|
@ -75,7 +76,8 @@ class VKPipeline : NonCopyable {
|
|||
void finalize(VKContext &context,
|
||||
VkShaderModule vertex_module,
|
||||
VkShaderModule fragment_module,
|
||||
VkPipelineLayout &pipeline_layout);
|
||||
VkPipelineLayout &pipeline_layout,
|
||||
const VKVertexAttributeObject &vertex_attribute_object);
|
||||
};
|
||||
|
||||
} // namespace blender::gpu
|
||||
|
|
|
@ -932,10 +932,10 @@ bool VKShader::transform_feedback_enable(GPUVertBuf *)
|
|||
|
||||
void VKShader::transform_feedback_disable() {}
|
||||
|
||||
void VKShader::update_graphics_pipeline(VKContext &context)
|
||||
void VKShader::update_graphics_pipeline(VKContext &context, const VKVertexAttributeObject &vertex_attribute_object)
|
||||
{
|
||||
BLI_assert(is_graphics_shader());
|
||||
pipeline_get().finalize(context, vertex_module_, fragment_module_, pipeline_layout_);
|
||||
pipeline_get().finalize(context, vertex_module_, fragment_module_, pipeline_layout_, vertex_attribute_object);
|
||||
}
|
||||
|
||||
void VKShader::bind()
|
||||
|
|
|
@ -70,7 +70,8 @@ class VKShader : public Shader {
|
|||
|
||||
const VKShaderInterface &interface_get() const;
|
||||
|
||||
void update_graphics_pipeline(VKContext &context);
|
||||
void update_graphics_pipeline(VKContext &context,
|
||||
const VKVertexAttributeObject &vertex_attribute_object);
|
||||
|
||||
private:
|
||||
Vector<uint32_t> compile_glsl_to_spirv(Span<const char *> sources, shaderc_shader_kind kind);
|
||||
|
|
Loading…
Reference in New Issue