WIP: Vulkan: Workbench #107886
|
@ -47,7 +47,10 @@ void VKBatch::draw(int vertex_first, int vertex_count, int instance_first, int i
|
|||
context.command_buffer_get().submit();
|
||||
}
|
||||
|
||||
void VKBatch::draw_indirect(GPUStorageBuf * /*indirect_buf*/, intptr_t /*offset*/) {}
|
||||
void VKBatch::draw_indirect(GPUStorageBuf * /*indirect_buf*/, intptr_t /*offset*/)
|
||||
{
|
||||
NOT_YET_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void VKBatch::multi_draw_indirect(GPUStorageBuf * /*indirect_buf*/,
|
||||
int /*count*/,
|
||||
|
|
|
@ -171,6 +171,7 @@ void VKCommandBuffer::copy(VKBuffer &dst_buffer,
|
|||
regions.size(),
|
||||
regions.data());
|
||||
}
|
||||
|
||||
void VKCommandBuffer::copy(VKTexture &dst_texture,
|
||||
VKBuffer &src_buffer,
|
||||
Span<VkBufferImageCopy> regions)
|
||||
|
@ -183,6 +184,21 @@ void VKCommandBuffer::copy(VKTexture &dst_texture,
|
|||
regions.size(),
|
||||
regions.data());
|
||||
}
|
||||
|
||||
void VKCommandBuffer::copy(VKTexture &dst_texture,
|
||||
VKTexture &src_texture,
|
||||
Span<VkImageCopy> regions)
|
||||
{
|
||||
ensure_no_active_framebuffer();
|
||||
vkCmdCopyImage(vk_command_buffer_,
|
||||
src_texture.vk_image_handle(),
|
||||
src_texture.current_layout_get(),
|
||||
dst_texture.vk_image_handle(),
|
||||
dst_texture.current_layout_get(),
|
||||
regions.size(),
|
||||
regions.data());
|
||||
}
|
||||
|
||||
void VKCommandBuffer::blit(VKTexture &dst_texture,
|
||||
VKTexture &src_buffer,
|
||||
Span<VkImageBlit> regions)
|
||||
|
|
|
@ -162,6 +162,7 @@ class VKCommandBuffer : NonCopyable, NonMovable {
|
|||
/** Copy the contents of a texture MIP level to the dst buffer. */
|
||||
void copy(VKBuffer &dst_buffer, VKTexture &src_texture, Span<VkBufferImageCopy> regions);
|
||||
void copy(VKTexture &dst_texture, VKBuffer &src_buffer, Span<VkBufferImageCopy> regions);
|
||||
void copy(VKTexture &dst_texture, VKTexture &src_texture, Span<VkImageCopy> regions);
|
||||
void blit(VKTexture &dst_texture, VKTexture &src_texture, Span<VkImageBlit> regions);
|
||||
void pipeline_barrier(VkPipelineStageFlags source_stages,
|
||||
VkPipelineStageFlags destination_stages);
|
||||
|
|
|
@ -128,7 +128,10 @@ class VKDescriptorSetTracker : protected VKResourceTracker<VKDescriptorSet> {
|
|||
|
||||
bool is_buffer() const
|
||||
{
|
||||
return ELEM(type, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
return ELEM(type,
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER);
|
||||
}
|
||||
|
||||
bool is_image() const
|
||||
|
|
|
@ -27,7 +27,6 @@ VKPipelineStateManager::VKPipelineStateManager()
|
|||
VK_COLOR_COMPONENT_G_BIT |
|
||||
VK_COLOR_COMPONENT_B_BIT |
|
||||
VK_COLOR_COMPONENT_A_BIT;
|
||||
color_blend_attachment_int_template = color_blend_attachment_template;
|
||||
}
|
||||
|
||||
void VKPipelineStateManager::set_state(const GPUState &state, const GPUStateMutable &mutable_state)
|
||||
|
@ -90,13 +89,7 @@ void VKPipelineStateManager::finalize_color_blend_state(const VKFrameBuffer &fra
|
|||
VKTexture *texture = unwrap(unwrap(framebuffer.color_tex(color_slot)));
|
||||
if (texture) {
|
||||
BLI_assert(is_sequential);
|
||||
eGPUTextureFormatFlag format_flag = texture->format_flag_get();
|
||||
if (format_flag & GPU_FORMAT_INTEGER) {
|
||||
color_blend_attachments.append(color_blend_attachment_int_template);
|
||||
}
|
||||
else {
|
||||
color_blend_attachments.append(color_blend_attachment_template);
|
||||
}
|
||||
color_blend_attachments.append(color_blend_attachment_template);
|
||||
}
|
||||
else {
|
||||
/* Test to detect if all color textures are sequential attached from the first slot. We
|
||||
|
|
|
@ -22,11 +22,7 @@ class VKPipelineStateManager {
|
|||
|
||||
public:
|
||||
VkPipelineColorBlendStateCreateInfo pipeline_color_blend_state;
|
||||
/* Template of the color blending for color attachments.
|
||||
* Blending is not supported on Integer based textures.
|
||||
*/
|
||||
VkPipelineColorBlendAttachmentState color_blend_attachment_template;
|
||||
VkPipelineColorBlendAttachmentState color_blend_attachment_int_template;
|
||||
Vector<VkPipelineColorBlendAttachmentState> color_blend_attachments;
|
||||
VkPipelineRasterizationStateCreateInfo rasterization_state;
|
||||
VkPipelineDepthStencilStateCreateInfo depth_stencil_state;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "vk_shader.hh"
|
||||
#include "vk_shader_interface.hh"
|
||||
#include "vk_state_manager.hh"
|
||||
#include "vk_vertex_buffer.hh"
|
||||
|
||||
#include "BLI_math_vector.hh"
|
||||
|
||||
|
@ -42,9 +43,34 @@ void VKTexture::generate_mipmap()
|
|||
NOT_YET_IMPLEMENTED
|
||||
}
|
||||
|
||||
void VKTexture::copy_to(Texture * /*tex*/)
|
||||
void VKTexture::copy_to(Texture *tex)
|
||||
{
|
||||
NOT_YET_IMPLEMENTED;
|
||||
VKTexture *dst = unwrap(tex);
|
||||
VKTexture *src = this;
|
||||
BLI_assert(dst);
|
||||
BLI_assert(src->w_ == dst->w_ && src->h_ == dst->h_ && src->d_ == dst->d_);
|
||||
BLI_assert(src->format_ == dst->format_);
|
||||
UNUSED_VARS_NDEBUG(src);
|
||||
|
||||
VKContext &context = *VKContext::get();
|
||||
layout_ensure(context, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
dst->ensure_allocated();
|
||||
dst->layout_ensure(context, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
|
||||
VkImageCopy region = {};
|
||||
region.srcSubresource.aspectMask = to_vk_image_aspect_flag_bits(format_);
|
||||
region.srcSubresource.mipLevel = 0;
|
||||
region.srcSubresource.layerCount = 1;
|
||||
region.dstSubresource.aspectMask = to_vk_image_aspect_flag_bits(format_);
|
||||
region.dstSubresource.mipLevel = 0;
|
||||
region.dstSubresource.layerCount = 1;
|
||||
region.extent.width = w_;
|
||||
region.extent.height = h_;
|
||||
region.extent.depth = d_;
|
||||
|
||||
VKCommandBuffer &command_buffer = context.command_buffer_get();
|
||||
command_buffer.copy(*dst, *this, Span<VkImageCopy>(®ion, 1));
|
||||
command_buffer.submit();
|
||||
}
|
||||
|
||||
void VKTexture::clear(eGPUDataFormat format, const void *data)
|
||||
|
@ -201,13 +227,34 @@ bool VKTexture::init_internal()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool VKTexture::init_internal(GPUVertBuf * /*vbo*/)
|
||||
bool VKTexture::init_internal(GPUVertBuf *vbo)
|
||||
{
|
||||
return false;
|
||||
if (!allocate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
VKVertexBuffer *vertex_buffer = unwrap(unwrap(vbo));
|
||||
|
||||
VkBufferImageCopy region = {};
|
||||
region.imageExtent.width = w_;
|
||||
region.imageExtent.height = 1;
|
||||
region.imageExtent.depth = 1;
|
||||
region.imageSubresource.aspectMask = to_vk_image_aspect_flag_bits(format_);
|
||||
region.imageSubresource.mipLevel = 0;
|
||||
region.imageSubresource.layerCount = 1;
|
||||
|
||||
VKContext &context = *VKContext::get();
|
||||
layout_ensure(context, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
VKCommandBuffer &command_buffer = context.command_buffer_get();
|
||||
command_buffer.copy(*this, vertex_buffer->buffer_, Span<VkBufferImageCopy>(®ion, 1));
|
||||
command_buffer.submit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VKTexture::init_internal(GPUTexture * /*src*/, int /*mip_offset*/, int /*layer_offset*/)
|
||||
{
|
||||
NOT_YET_IMPLEMENTED;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,8 @@ void VKVertexBuffer::allocate()
|
|||
{
|
||||
buffer_.create(size_alloc_get(),
|
||||
usage_,
|
||||
static_cast<VkBufferUsageFlagBits>(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
|
||||
static_cast<VkBufferUsageFlagBits>(VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
|
||||
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
|
||||
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT));
|
||||
debug::object_label(buffer_.vk_handle(), "VertexBuffer");
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "vk_buffer.hh"
|
||||
|
||||
namespace blender::gpu {
|
||||
class VKTexture;
|
||||
|
||||
class VKVertexBuffer : public VertBuf {
|
||||
VKBuffer buffer_;
|
||||
|
@ -42,6 +43,9 @@ class VKVertexBuffer : public VertBuf {
|
|||
private:
|
||||
void allocate();
|
||||
void *convert() const;
|
||||
|
||||
/* VKTexture requires access to `buffer_` to convert a vertex buffer to a texture.*/
|
||||
friend class VKTexture;
|
||||
};
|
||||
|
||||
static inline VKVertexBuffer *unwrap(VertBuf *vertex_buffer)
|
||||
|
|
Loading…
Reference in New Issue