diff --git a/engine/renderer/src/dofpass.cpp b/engine/renderer/src/dofpass.cpp index d0a7d42..70c2d88 100755 --- a/engine/renderer/src/dofpass.cpp +++ b/engine/renderer/src/dofpass.cpp @@ -32,7 +32,7 @@ DoFPass::DoFPass(GFX* gfx, Renderer* renderer) : renderer(renderer) { create_info.shaders.fragment_path = "dof.frag"; create_info.shader_input.bindings = { - {0, GFXBindingType::SampledImage}, + {0, GFXBindingType::StorageImage}, {1, GFXBindingType::Texture}, {3, GFXBindingType::Texture}, {2, GFXBindingType::PushConstant} diff --git a/engine/renderer/src/renderer.cpp b/engine/renderer/src/renderer.cpp index a93aa9a..71349c5 100755 --- a/engine/renderer/src/renderer.cpp +++ b/engine/renderer/src/renderer.cpp @@ -728,11 +728,11 @@ void Renderer::create_mesh_pipeline(Material& material) { pipelineInfo.shader_input.bindings = { {1, GFXBindingType::StorageBuffer}, {0, GFXBindingType::PushConstant}, - {2, GFXBindingType::SampledImage}, + {2, GFXBindingType::StorageImage}, {3, GFXBindingType::SampledImage}, {4, GFXBindingType::Sampler}, {5, GFXBindingType::Sampler}, - {6, GFXBindingType::SampledImage}, + {6, GFXBindingType::StorageImage}, {7, GFXBindingType::Texture}, {8, GFXBindingType::Texture}, {9, GFXBindingType::Texture} diff --git a/shaders/billboard.frag.glsl b/shaders/billboard.frag.glsl index 8422fe0..27ecec2 100755 --- a/shaders/billboard.frag.glsl +++ b/shaders/billboard.frag.glsl @@ -3,7 +3,7 @@ layout (location = 0) in vec2 inUV; layout (location = 0) out vec4 outColor; layout(push_constant, binding = 1) uniform readonly PushConstant{ - mat4 view, mvp; + mat4 mvp; vec4 color; }; diff --git a/shaders/billboard.vert.glsl b/shaders/billboard.vert.glsl index 6d4b20b..da8fffc 100755 --- a/shaders/billboard.vert.glsl +++ b/shaders/billboard.vert.glsl @@ -1,10 +1,14 @@ layout (location = 0) out vec2 outUV; layout(push_constant, binding = 1) uniform readonly PushConstant{ - mat4 view, mvp; + mat4 mvp; vec4 color; }; +layout(std430, binding = 3) buffer readonly SceneInformation { + mat4 view; +}; + void main() { vec2 p = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2); outUV = vec2(p.x, 1.0 - p.y); diff --git a/tools/common/include/debugpass.hpp b/tools/common/include/debugpass.hpp index ac7e5c9..a9f3461 100755 --- a/tools/common/include/debugpass.hpp +++ b/tools/common/include/debugpass.hpp @@ -89,4 +89,6 @@ private: GFXPipeline* sobelPipeline = nullptr; GFXFramebuffer* sobelFramebuffer = nullptr; GFXRenderPass* sobelRenderPass = nullptr; + + GFXBuffer* scene_info_buffer = nullptr; }; diff --git a/tools/common/src/debugpass.cpp b/tools/common/src/debugpass.cpp index 34e1b64..94cfea1 100755 --- a/tools/common/src/debugpass.cpp +++ b/tools/common/src/debugpass.cpp @@ -12,11 +12,13 @@ #include "renderer.hpp" struct BillPushConstant { - Matrix4x4 view, mvp; + Matrix4x4 mvp; Vector4 color; }; void DebugPass::initialize() { + scene_info_buffer = engine->get_gfx()->create_buffer(nullptr, sizeof(Matrix4x4), true, GFXBufferUsage::Storage); + { GFXGraphicsPipelineCreateInfo createInfo; createInfo.shaders.vertex_path = "debug.vert"; @@ -141,7 +143,9 @@ void DebugPass::initialize() { pipelineInfo.shaders.fragment_path = "billboard.frag"; pipelineInfo.shader_input.bindings = { - {1, GFXBindingType::PushConstant} + {1, GFXBindingType::PushConstant}, + {2, GFXBindingType::Texture}, + {3, GFXBindingType::StorageBuffer} }; pipelineInfo.shader_input.push_constants = { @@ -339,17 +343,19 @@ void DebugPass::render_scene(Scene& scene, GFXCommandBuffer* commandBuffer) { } commandBuffer->set_graphics_pipeline(billboard_pipeline); - + + engine->get_gfx()->copy_buffer(scene_info_buffer, &camera.view, 0, sizeof(Matrix4x4)); + // draw primitives for(auto& bill : billboards) { Matrix4x4 m = transform::translate(Matrix4x4(), bill.position); BillPushConstant pc; - pc.view = camera.view; pc.mvp = vp * m; pc.color = bill.color; 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->draw_indexed(4, 0, 0, 0);