Archived
1
Fork 0

More vulkan fixes

This commit is contained in:
redstrate 2021-02-03 06:55:46 -05:00
parent 97f67560df
commit 0c3c879497
6 changed files with 21 additions and 9 deletions

View file

@ -32,7 +32,7 @@ DoFPass::DoFPass(GFX* gfx, Renderer* renderer) : renderer(renderer) {
create_info.shaders.fragment_path = "dof.frag"; create_info.shaders.fragment_path = "dof.frag";
create_info.shader_input.bindings = { create_info.shader_input.bindings = {
{0, GFXBindingType::SampledImage}, {0, GFXBindingType::StorageImage},
{1, GFXBindingType::Texture}, {1, GFXBindingType::Texture},
{3, GFXBindingType::Texture}, {3, GFXBindingType::Texture},
{2, GFXBindingType::PushConstant} {2, GFXBindingType::PushConstant}

View file

@ -728,11 +728,11 @@ void Renderer::create_mesh_pipeline(Material& material) {
pipelineInfo.shader_input.bindings = { pipelineInfo.shader_input.bindings = {
{1, GFXBindingType::StorageBuffer}, {1, GFXBindingType::StorageBuffer},
{0, GFXBindingType::PushConstant}, {0, GFXBindingType::PushConstant},
{2, GFXBindingType::SampledImage}, {2, GFXBindingType::StorageImage},
{3, GFXBindingType::SampledImage}, {3, GFXBindingType::SampledImage},
{4, GFXBindingType::Sampler}, {4, GFXBindingType::Sampler},
{5, GFXBindingType::Sampler}, {5, GFXBindingType::Sampler},
{6, GFXBindingType::SampledImage}, {6, GFXBindingType::StorageImage},
{7, GFXBindingType::Texture}, {7, GFXBindingType::Texture},
{8, GFXBindingType::Texture}, {8, GFXBindingType::Texture},
{9, GFXBindingType::Texture} {9, GFXBindingType::Texture}

View file

@ -3,7 +3,7 @@ layout (location = 0) in vec2 inUV;
layout (location = 0) out vec4 outColor; layout (location = 0) out vec4 outColor;
layout(push_constant, binding = 1) uniform readonly PushConstant{ layout(push_constant, binding = 1) uniform readonly PushConstant{
mat4 view, mvp; mat4 mvp;
vec4 color; vec4 color;
}; };

View file

@ -1,10 +1,14 @@
layout (location = 0) out vec2 outUV; layout (location = 0) out vec2 outUV;
layout(push_constant, binding = 1) uniform readonly PushConstant{ layout(push_constant, binding = 1) uniform readonly PushConstant{
mat4 view, mvp; mat4 mvp;
vec4 color; vec4 color;
}; };
layout(std430, binding = 3) buffer readonly SceneInformation {
mat4 view;
};
void main() { void main() {
vec2 p = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2); vec2 p = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
outUV = vec2(p.x, 1.0 - p.y); outUV = vec2(p.x, 1.0 - p.y);

View file

@ -89,4 +89,6 @@ private:
GFXPipeline* sobelPipeline = nullptr; GFXPipeline* sobelPipeline = nullptr;
GFXFramebuffer* sobelFramebuffer = nullptr; GFXFramebuffer* sobelFramebuffer = nullptr;
GFXRenderPass* sobelRenderPass = nullptr; GFXRenderPass* sobelRenderPass = nullptr;
GFXBuffer* scene_info_buffer = nullptr;
}; };

View file

@ -12,11 +12,13 @@
#include "renderer.hpp" #include "renderer.hpp"
struct BillPushConstant { struct BillPushConstant {
Matrix4x4 view, mvp; Matrix4x4 mvp;
Vector4 color; Vector4 color;
}; };
void DebugPass::initialize() { void DebugPass::initialize() {
scene_info_buffer = engine->get_gfx()->create_buffer(nullptr, sizeof(Matrix4x4), true, GFXBufferUsage::Storage);
{ {
GFXGraphicsPipelineCreateInfo createInfo; GFXGraphicsPipelineCreateInfo createInfo;
createInfo.shaders.vertex_path = "debug.vert"; createInfo.shaders.vertex_path = "debug.vert";
@ -141,7 +143,9 @@ void DebugPass::initialize() {
pipelineInfo.shaders.fragment_path = "billboard.frag"; pipelineInfo.shaders.fragment_path = "billboard.frag";
pipelineInfo.shader_input.bindings = { pipelineInfo.shader_input.bindings = {
{1, GFXBindingType::PushConstant} {1, GFXBindingType::PushConstant},
{2, GFXBindingType::Texture},
{3, GFXBindingType::StorageBuffer}
}; };
pipelineInfo.shader_input.push_constants = { pipelineInfo.shader_input.push_constants = {
@ -340,16 +344,18 @@ void DebugPass::render_scene(Scene& scene, GFXCommandBuffer* commandBuffer) {
commandBuffer->set_graphics_pipeline(billboard_pipeline); commandBuffer->set_graphics_pipeline(billboard_pipeline);
engine->get_gfx()->copy_buffer(scene_info_buffer, &camera.view, 0, sizeof(Matrix4x4));
// draw primitives // draw primitives
for(auto& bill : billboards) { for(auto& bill : billboards) {
Matrix4x4 m = transform::translate(Matrix4x4(), bill.position); Matrix4x4 m = transform::translate(Matrix4x4(), bill.position);
BillPushConstant pc; BillPushConstant pc;
pc.view = camera.view;
pc.mvp = vp * m; pc.mvp = vp * m;
pc.color = bill.color; pc.color = bill.color;
commandBuffer->bind_texture(bill.texture, 2); commandBuffer->bind_texture(bill.texture, 2);
commandBuffer->bind_shader_buffer(scene_info_buffer, 0, 3, sizeof(Matrix4x4));
commandBuffer->set_push_constant(&pc, sizeof(BillPushConstant)); commandBuffer->set_push_constant(&pc, sizeof(BillPushConstant));
commandBuffer->draw_indexed(4, 0, 0, 0); commandBuffer->draw_indexed(4, 0, 0, 0);