Basic UI quad, yay
This commit is contained in:
@@ -30,7 +30,7 @@ public:
|
||||
virtual PWindow createWindow(const WindowCreateInfo &createInfo) = 0;
|
||||
virtual PViewport createViewport(PWindow owner, const ViewportCreateInfo &createInfo) = 0;
|
||||
|
||||
virtual PRenderPass createRenderPass(PRenderTargetLayout layout) = 0;
|
||||
virtual PRenderPass createRenderPass(PRenderTargetLayout layout, PViewport renderArea) = 0;
|
||||
virtual void beginRenderPass(PRenderPass renderPass) = 0;
|
||||
virtual void endRenderPass() = 0;
|
||||
|
||||
|
||||
@@ -549,6 +549,7 @@ public:
|
||||
virtual void bindVertexBuffer(const Array<VertexInputStream>& streams) = 0;
|
||||
virtual void bindIndexBuffer(Gfx::PIndexBuffer indexBuffer) = 0;
|
||||
virtual void draw(const MeshBatchElement& data) = 0;
|
||||
virtual void draw(uint32 vertexCount, uint32 instanceCount, int32 firstVertex, uint32 firstInstance) = 0;
|
||||
std::string name;
|
||||
};
|
||||
DEFINE_REF(RenderCommand)
|
||||
@@ -588,6 +589,14 @@ public:
|
||||
{
|
||||
return samples;
|
||||
}
|
||||
uint32 getSizeX() const
|
||||
{
|
||||
return sizeX;
|
||||
}
|
||||
uint32 getSizeY() const
|
||||
{
|
||||
return sizeY;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32 sizeX;
|
||||
@@ -628,7 +637,11 @@ public:
|
||||
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
||||
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE)
|
||||
: loadOp(loadOp), storeOp(storeOp), stencilLoadOp(stencilLoadOp), stencilStoreOp(stencilStoreOp), texture(texture)
|
||||
: loadOp(loadOp)
|
||||
, storeOp(storeOp)
|
||||
, stencilLoadOp(stencilLoadOp)
|
||||
, stencilStoreOp(stencilStoreOp)
|
||||
, texture(texture)
|
||||
{
|
||||
}
|
||||
virtual ~RenderTargetAttachment()
|
||||
@@ -646,6 +659,14 @@ public:
|
||||
{
|
||||
return texture->getNumSamples();
|
||||
}
|
||||
virtual uint32 getSizeX() const
|
||||
{
|
||||
return texture->getSizeX();
|
||||
}
|
||||
virtual uint32 getSizeY() const
|
||||
{
|
||||
return texture->getSizeY();
|
||||
}
|
||||
inline SeAttachmentLoadOp getLoadOp() const { return loadOp; }
|
||||
inline SeAttachmentStoreOp getStoreOp() const { return storeOp; }
|
||||
inline SeAttachmentLoadOp getStencilLoadOp() const { return stencilLoadOp; }
|
||||
@@ -665,7 +686,7 @@ class SwapchainAttachment : public RenderTargetAttachment
|
||||
{
|
||||
public:
|
||||
SwapchainAttachment(PWindow owner,
|
||||
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_CLEAR,
|
||||
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_LOAD,
|
||||
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
||||
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE)
|
||||
@@ -689,7 +710,14 @@ public:
|
||||
{
|
||||
return owner->getNumSamples();
|
||||
}
|
||||
|
||||
virtual uint32 getSizeX() const
|
||||
{
|
||||
return owner->getSizeX();
|
||||
}
|
||||
virtual uint32 getSizeY() const
|
||||
{
|
||||
return owner->getSizeY();
|
||||
}
|
||||
private:
|
||||
PWindow owner;
|
||||
};
|
||||
|
||||
@@ -4,44 +4,6 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
/*#define MAX_TEX_CHANNELS 8
|
||||
struct MeshDescription
|
||||
{
|
||||
Array<Gfx::VertexAttribute> layout;
|
||||
Gfx::PVertexDeclaration declaration;
|
||||
uint32 getStride() const
|
||||
{
|
||||
return getNumFloats() * sizeof(float);
|
||||
}
|
||||
uint32 getNumFloats() const
|
||||
{
|
||||
uint32 vertexSize = 0;
|
||||
for(auto a : layout)
|
||||
{
|
||||
switch (a)
|
||||
{
|
||||
case Gfx::VertexAttribute::POSITION:
|
||||
case Gfx::VertexAttribute::NORMAL:
|
||||
case Gfx::VertexAttribute::TANGENT:
|
||||
case Gfx::VertexAttribute::BITANGENT:
|
||||
vertexSize += 3;
|
||||
break;
|
||||
case Gfx::VertexAttribute::TEXCOORD:
|
||||
vertexSize += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return vertexSize;
|
||||
}
|
||||
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(Archive& ar, const unsigned int version)
|
||||
{
|
||||
ar & layout;
|
||||
//TODO declaration
|
||||
}
|
||||
};*/
|
||||
DECLARE_REF(MaterialAsset)
|
||||
class Mesh
|
||||
{
|
||||
|
||||
@@ -80,11 +80,9 @@ void BasePassMeshProcessor::clearCommands()
|
||||
}
|
||||
|
||||
BasePass::BasePass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
||||
: RenderPass(renderGraph)
|
||||
: RenderPass(renderGraph, graphics, viewport)
|
||||
, processor(new BasePassMeshProcessor(scene, viewport, graphics, false))
|
||||
, scene(scene)
|
||||
, graphics(graphics)
|
||||
, viewport(viewport)
|
||||
, descriptorSets(4)
|
||||
, source(source->getCameraComponent())
|
||||
{
|
||||
@@ -198,7 +196,7 @@ void BasePass::createRenderPass()
|
||||
Gfx::PRenderTargetAttachment depthAttachment = renderGraph->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
||||
depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
|
||||
Gfx::PRenderTargetLayout layout = new Gfx::RenderTargetLayout(colorAttachment, depthAttachment);
|
||||
renderPass = graphics->createRenderPass(layout);
|
||||
renderPass = graphics->createRenderPass(layout, viewport);
|
||||
oLightIndexList = renderGraph->requestBuffer("LIGHTCULLING_OLIGHTLIST");
|
||||
oLightGrid = renderGraph->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
||||
}
|
||||
|
||||
@@ -46,9 +46,8 @@ private:
|
||||
Gfx::PRenderTargetAttachment colorAttachment;
|
||||
Gfx::PTexture2D depthBuffer;
|
||||
UPBasePassMeshProcessor processor;
|
||||
|
||||
const PScene scene;
|
||||
Gfx::PGraphics graphics;
|
||||
Gfx::PViewport viewport;
|
||||
Array<Gfx::PDescriptorSet> descriptorSets;
|
||||
PCameraComponent source;
|
||||
Gfx::PPipelineLayout basePassLayout;
|
||||
|
||||
@@ -11,4 +11,6 @@ target_sources(SeeleEngine
|
||||
RenderGraph.h
|
||||
RenderGraph.cpp
|
||||
RenderPass.h
|
||||
RenderPass.cpp)
|
||||
RenderPass.cpp
|
||||
UIPass.h
|
||||
UIPass.cpp)
|
||||
@@ -79,11 +79,9 @@ void DepthPrepassMeshProcessor::clearCommands()
|
||||
}
|
||||
|
||||
DepthPrepass::DepthPrepass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
||||
: RenderPass(renderGraph)
|
||||
: RenderPass(renderGraph, graphics, viewport)
|
||||
, processor(new DepthPrepassMeshProcessor(scene, viewport, graphics))
|
||||
, scene(scene)
|
||||
, graphics(graphics)
|
||||
, viewport(viewport)
|
||||
, descriptorSets(3)
|
||||
, source(source->getCameraComponent())
|
||||
{
|
||||
@@ -156,8 +154,10 @@ void DepthPrepass::endFrame()
|
||||
void DepthPrepass::publishOutputs()
|
||||
{
|
||||
TextureCreateInfo depthBufferInfo;
|
||||
depthBufferInfo.width = viewport->getSizeX();
|
||||
depthBufferInfo.height = viewport->getSizeY();
|
||||
// If we render to a part of an image, the depth buffer itself must
|
||||
// still match the size of the whole image or their coordinate systems go out of sync
|
||||
depthBufferInfo.width = viewport->getOwner()->getSizeX();
|
||||
depthBufferInfo.height = viewport->getOwner()->getSizeY();
|
||||
depthBufferInfo.format = Gfx::SE_FORMAT_D32_SFLOAT;
|
||||
depthBufferInfo.usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
depthBuffer = graphics->createTexture2D(depthBufferInfo);
|
||||
@@ -170,7 +170,7 @@ void DepthPrepass::publishOutputs()
|
||||
void DepthPrepass::createRenderPass()
|
||||
{
|
||||
Gfx::PRenderTargetLayout layout = new Gfx::RenderTargetLayout(depthAttachment);
|
||||
renderPass = graphics->createRenderPass(layout);
|
||||
renderPass = graphics->createRenderPass(layout, viewport);
|
||||
}
|
||||
|
||||
void DepthPrepass::modifyRenderPassMacros(Map<const char*, const char*>& defines)
|
||||
|
||||
@@ -46,8 +46,7 @@ private:
|
||||
Gfx::PTexture2D depthBuffer;
|
||||
UPDepthPrepassMeshProcessor processor;
|
||||
const PScene scene;
|
||||
Gfx::PGraphics graphics;
|
||||
Gfx::PViewport viewport;
|
||||
|
||||
Array<Gfx::PDescriptorSet> descriptorSets;
|
||||
PCameraComponent source;
|
||||
Gfx::PPipelineLayout depthPrepassLayout;
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
using namespace Seele;
|
||||
|
||||
LightCullingPass::LightCullingPass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera)
|
||||
: RenderPass(renderGraph)
|
||||
: RenderPass(renderGraph, graphics, viewport)
|
||||
, scene(scene)
|
||||
, viewport(viewport)
|
||||
, graphics(graphics)
|
||||
, source(camera->getCameraComponent())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,9 +44,7 @@ private:
|
||||
};
|
||||
|
||||
PScene scene;
|
||||
Gfx::PViewport viewport;
|
||||
Gfx::PGraphics graphics;
|
||||
|
||||
|
||||
Gfx::PStructuredBuffer frustumBuffer;
|
||||
Gfx::PUniformBuffer dispatchParamsBuffer;
|
||||
Gfx::PUniformBuffer viewParamsBuffer;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
RenderPass::RenderPass(PRenderGraph renderGraph)
|
||||
: renderGraph(renderGraph)
|
||||
RenderPass::RenderPass(PRenderGraph renderGraph, Gfx::PGraphics graphics, Gfx::PViewport viewport)
|
||||
: renderGraph(renderGraph), graphics(graphics), viewport(viewport)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_NAME_REF(Gfx, Viewport)
|
||||
DECLARE_NAME_REF(Gfx, Graphics)
|
||||
DECLARE_NAME_REF(Gfx, RenderPass)
|
||||
DECLARE_REF(RenderGraph)
|
||||
class RenderPass
|
||||
{
|
||||
public:
|
||||
RenderPass(PRenderGraph rendergraph);
|
||||
RenderPass(PRenderGraph rendergraph, Gfx::PGraphics graphics, Gfx::PViewport viewport);
|
||||
virtual ~RenderPass();
|
||||
virtual void beginFrame() = 0;
|
||||
virtual void render() = 0;
|
||||
@@ -27,6 +29,8 @@ protected:
|
||||
} viewParams;
|
||||
Gfx::PRenderPass renderPass;
|
||||
PRenderGraph renderGraph;
|
||||
Gfx::PGraphics graphics;
|
||||
Gfx::PViewport viewport;
|
||||
};
|
||||
DEFINE_REF(RenderPass)
|
||||
} // namespace Seele
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#include "UIPass.h"
|
||||
#include "RenderGraph.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
UIPass::UIPass(PRenderGraph renderGraph, Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment attachment)
|
||||
: RenderPass(renderGraph, graphics, viewport)
|
||||
, renderTarget(attachment)
|
||||
{
|
||||
}
|
||||
|
||||
UIPass::~UIPass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UIPass::beginFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UIPass::render()
|
||||
{
|
||||
graphics->beginRenderPass(renderPass);
|
||||
Gfx::PRenderCommand command = graphics->createRenderCommand("UIPassCommand");
|
||||
command->setViewport(viewport);
|
||||
command->bindPipeline(pipeline);
|
||||
command->draw(4, 1, 0, 0);
|
||||
graphics->executeCommands(Array<Gfx::PRenderCommand>({command}));
|
||||
graphics->endRenderPass();
|
||||
}
|
||||
|
||||
void UIPass::endFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UIPass::publishOutputs()
|
||||
{
|
||||
TextureCreateInfo depthBufferInfo;
|
||||
// Even if we only render to part of an image, we need to make sure
|
||||
// that the depthbuffer is the same size or they can't be used in the same
|
||||
// framebuffer
|
||||
depthBufferInfo.width = viewport->getOwner()->getSizeX();
|
||||
depthBufferInfo.height = viewport->getOwner()->getSizeY();
|
||||
depthBufferInfo.format = Gfx::SE_FORMAT_D32_SFLOAT;
|
||||
depthBufferInfo.usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
|
||||
depthBuffer = graphics->createTexture2D(depthBufferInfo);
|
||||
depthAttachment =
|
||||
new Gfx::RenderTargetAttachment(depthBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
depthAttachment->clear.depthStencil.depth = 1.0f;
|
||||
renderGraph->registerRenderPassOutput("UIPASS_DEPTH", depthAttachment);
|
||||
}
|
||||
|
||||
void UIPass::createRenderPass()
|
||||
{
|
||||
std::ifstream codeStream("./shaders/UIPass.slang", std::ios::ate);
|
||||
auto fileSize = codeStream.tellg();
|
||||
codeStream.seekg(0);
|
||||
Array<char> buffer(static_cast<uint32>(fileSize));
|
||||
codeStream.read(buffer.data(), fileSize);
|
||||
|
||||
ShaderCreateInfo createInfo;
|
||||
createInfo.shaderCode.add(std::string(buffer.data()));
|
||||
createInfo.name = "UIVertex";
|
||||
createInfo.entryPoint = "vertexMain";
|
||||
vertexShader = graphics->createVertexShader(createInfo);
|
||||
|
||||
createInfo.name = "UIFragment";
|
||||
createInfo.entryPoint = "fragmentMain";
|
||||
fragmentShader = graphics->createFragmentShader(createInfo);
|
||||
declaration = graphics->createVertexDeclaration({});
|
||||
pipelineLayout = graphics->createPipelineLayout();
|
||||
pipelineLayout->create();
|
||||
|
||||
Gfx::PRenderTargetLayout layout = new Gfx::RenderTargetLayout(renderTarget, depthAttachment);
|
||||
renderPass = graphics->createRenderPass(layout, viewport);
|
||||
|
||||
GraphicsPipelineCreateInfo pipelineInfo;
|
||||
pipelineInfo.vertexDeclaration = declaration;
|
||||
pipelineInfo.vertexShader = vertexShader;
|
||||
pipelineInfo.fragmentShader = fragmentShader;
|
||||
pipelineInfo.renderPass = renderPass;
|
||||
pipelineInfo.pipelineLayout = pipelineLayout;
|
||||
pipelineInfo.rasterizationState.cullMode = Gfx::SE_CULL_MODE_NONE;
|
||||
pipelineInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
|
||||
|
||||
pipeline = graphics->createGraphicsPipeline(pipelineInfo);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "RenderPass.h"
|
||||
#include "UI/RenderHierarchy.h"
|
||||
#include "Graphics/GraphicsResources.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_NAME_REF(Gfx, Texture2D)
|
||||
DECLARE_NAME_REF(Gfx, RenderTargetAttachment)
|
||||
class UIPass : public RenderPass
|
||||
{
|
||||
public:
|
||||
UIPass(PRenderGraph renderGraph, Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment renderTarget);
|
||||
virtual ~UIPass();
|
||||
virtual void beginFrame() override;
|
||||
virtual void render() override;
|
||||
virtual void endFrame() override;
|
||||
virtual void publishOutputs() override;
|
||||
virtual void createRenderPass() override;
|
||||
private:
|
||||
UI::RenderHierarchy hierarchy;
|
||||
Gfx::PRenderTargetAttachment renderTarget;
|
||||
Gfx::PRenderTargetAttachment depthAttachment;
|
||||
Gfx::PTexture2D depthBuffer;
|
||||
|
||||
Gfx::PVertexDeclaration declaration;
|
||||
Gfx::PVertexShader vertexShader;
|
||||
Gfx::PFragmentShader fragmentShader;
|
||||
Gfx::PPipelineLayout pipelineLayout;
|
||||
Gfx::PGraphicsPipeline pipeline;
|
||||
};
|
||||
DEFINE_REF(UIPass);
|
||||
} // namespace Seele
|
||||
@@ -140,8 +140,8 @@ void ShaderBuffer::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
||||
dynamicBarriers[i] = barrier;
|
||||
dynamicBarriers[i].buffer = buffers[i].buffer;
|
||||
}
|
||||
vkCmdPipelineBarrier(srcCommand, srcStage, dstStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr);
|
||||
vkCmdPipelineBarrier(dstCommand, srcStage, dstStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr);
|
||||
vkCmdPipelineBarrier(srcCommand, srcStage, srcStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr);
|
||||
vkCmdPipelineBarrier(dstCommand, dstStage, dstStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr);
|
||||
sourceManager->submitCommands();
|
||||
}
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet)
|
||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
||||
boundDescriptors.add(descriptor.getHandle());
|
||||
descriptor->bind();
|
||||
//std::cout << "Binding descriptor " << descriptor->getHandle() << " to cmd " << handle << std::endl;
|
||||
|
||||
VkDescriptorSet setHandle = descriptor->getHandle();
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->getLayout(), descriptorSet->getSetIndex(), 1, &setHandle, 0, nullptr);
|
||||
}
|
||||
@@ -261,7 +261,7 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
|
||||
{
|
||||
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
||||
descriptorSet->bind();
|
||||
//std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
|
||||
|
||||
boundDescriptors.add(descriptorSet.getHandle());
|
||||
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle();
|
||||
}
|
||||
@@ -290,6 +290,11 @@ void RenderCommand::draw(const MeshBatchElement& data)
|
||||
vkCmdDrawIndexed(handle, data.indexBuffer->getNumIndices(), data.numInstances, data.minVertexIndex, data.baseVertexIndex, 0);
|
||||
}
|
||||
|
||||
void RenderCommand::draw(uint32 vertexCount, uint32 instanceCount, int32 firstVertex, uint32 firstInstance)
|
||||
{
|
||||
vkCmdDraw(handle, vertexCount, instanceCount, firstVertex, firstInstance);
|
||||
}
|
||||
|
||||
ComputeCommand::ComputeCommand(PGraphics graphics, VkCommandPool cmdPool)
|
||||
: SecondaryCmdBuffer(graphics, cmdPool)
|
||||
{
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
virtual void bindVertexBuffer(const Array<VertexInputStream>& streams) override;
|
||||
virtual void bindIndexBuffer(Gfx::PIndexBuffer indexBuffer) override;
|
||||
virtual void draw(const MeshBatchElement& data) override;
|
||||
|
||||
virtual void draw(uint32 vertexCount, uint32 instanceCount, int32 firstVertex, uint32 firstInstance) override;
|
||||
private:
|
||||
PGraphicsPipeline pipeline;
|
||||
friend class CmdBuffer;
|
||||
|
||||
@@ -13,31 +13,39 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::PRende
|
||||
FramebufferDescription description;
|
||||
std::memset(&description, 0, sizeof(FramebufferDescription));
|
||||
Array<VkImageView> attachments;
|
||||
uint32 sizeX = 0;
|
||||
uint32 sizeY = 0;
|
||||
for (auto inputAttachment : layout->inputAttachments)
|
||||
{
|
||||
PTexture2D vkInputAttachment = inputAttachment->getTexture().cast<Texture2D>();
|
||||
attachments.add(vkInputAttachment->getView());
|
||||
description.inputAttachments[description.numInputAttachments++] = vkInputAttachment->getView();
|
||||
sizeX = std::max(sizeX, vkInputAttachment->getSizeX());
|
||||
sizeY = std::max(sizeY, vkInputAttachment->getSizeY());
|
||||
}
|
||||
for (auto colorAttachment : layout->colorAttachments)
|
||||
{
|
||||
PTexture2D vkColorAttachment = colorAttachment->getTexture().cast<Texture2D>();
|
||||
attachments.add(vkColorAttachment->getView());
|
||||
description.colorAttachments[description.numColorAttachments++] = vkColorAttachment->getView();
|
||||
sizeX = std::max(sizeX, vkColorAttachment->getSizeX());
|
||||
sizeY = std::max(sizeY, vkColorAttachment->getSizeY());
|
||||
}
|
||||
if (layout->depthAttachment != nullptr)
|
||||
{
|
||||
PTexture2D vkDepthAttachment = layout->depthAttachment->getTexture().cast<Texture2D>();
|
||||
attachments.add(vkDepthAttachment->getView());
|
||||
description.depthAttachment = vkDepthAttachment->getView();
|
||||
sizeX = std::max(sizeX, vkDepthAttachment->getSizeX());
|
||||
sizeY = std::max(sizeY, vkDepthAttachment->getSizeY());
|
||||
}
|
||||
VkFramebufferCreateInfo createInfo =
|
||||
init::FramebufferCreateInfo(
|
||||
renderPass->getHandle(),
|
||||
(uint32)attachments.size(),
|
||||
attachments.data(),
|
||||
renderPass->getRenderArea().extent.width,
|
||||
renderPass->getRenderArea().extent.height,
|
||||
sizeX,
|
||||
sizeY,
|
||||
1);
|
||||
|
||||
VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle));
|
||||
|
||||
@@ -55,9 +55,9 @@ Gfx::PViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate
|
||||
viewports.add(result);
|
||||
return result;
|
||||
}
|
||||
Gfx::PRenderPass Graphics::createRenderPass(Gfx::PRenderTargetLayout layout)
|
||||
Gfx::PRenderPass Graphics::createRenderPass(Gfx::PRenderTargetLayout layout, Gfx::PViewport renderArea)
|
||||
{
|
||||
PRenderPass result = new RenderPass(this, layout);
|
||||
PRenderPass result = new RenderPass(this, layout, renderArea);
|
||||
return result;
|
||||
}
|
||||
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass)
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
virtual Gfx::PWindow createWindow(const WindowCreateInfo &createInfo) override;
|
||||
virtual Gfx::PViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo &createInfo) override;
|
||||
|
||||
virtual Gfx::PRenderPass createRenderPass(Gfx::PRenderTargetLayout layout) override;
|
||||
virtual Gfx::PRenderPass createRenderPass(Gfx::PRenderTargetLayout layout, Gfx::PViewport renderArea) override;
|
||||
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
|
||||
virtual void endRenderPass() override;
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::Vulkan;
|
||||
|
||||
RenderPass::RenderPass(PGraphics graphics, Gfx::PRenderTargetLayout layout)
|
||||
RenderPass::RenderPass(PGraphics graphics, Gfx::PRenderTargetLayout layout, Gfx::PViewport viewport)
|
||||
: Gfx::RenderPass(layout)
|
||||
, graphics(graphics)
|
||||
{
|
||||
renderArea.extent.width = layout->width;
|
||||
renderArea.extent.height = layout->height;
|
||||
renderArea.offset.x = 0;
|
||||
renderArea.offset.y = 0;
|
||||
renderArea.extent.width = viewport->getSizeX();
|
||||
renderArea.extent.height = viewport->getSizeY();
|
||||
renderArea.offset.x = viewport->getOffsetX();
|
||||
renderArea.offset.y = viewport->getOffsetY();
|
||||
subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
|
||||
Array<VkAttachmentDescription> attachments;
|
||||
Array<VkAttachmentReference> inputRefs;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Vulkan
|
||||
class RenderPass : public Gfx::RenderPass
|
||||
{
|
||||
public:
|
||||
RenderPass(PGraphics graphics, Gfx::PRenderTargetLayout layout);
|
||||
RenderPass(PGraphics graphics, Gfx::PRenderTargetLayout layout, Gfx::PViewport viewport);
|
||||
virtual ~RenderPass();
|
||||
uint32 getFramebufferHash();
|
||||
inline VkRenderPass getHandle() const
|
||||
|
||||
@@ -52,39 +52,6 @@ static SlangStage getStageFromShaderType(ShaderType type)
|
||||
}
|
||||
}
|
||||
|
||||
/*static void createMixedDescriptorLayout(PDescriptorLayout layout, VariableLayoutReflection* parameter)
|
||||
{
|
||||
//std::cout << "category: " << (uint32)parameter->ge << std::endl;
|
||||
uint32 categoryCount = parameter->getCategoryCount();
|
||||
std::cout << "Mixed parameter " << parameter->getName() << " with categories: " << std::endl;
|
||||
for(uint32 i = 0; i < categoryCount; ++i)
|
||||
{
|
||||
ParameterCategory category = parameter->getCategoryByIndex(i);
|
||||
uint32 offset = parameter->getOffset(category);
|
||||
uint32 space = parameter->getBindingSpace(category);
|
||||
std::cout << "category: " << category << std::endl << " offset: " << offset << std::endl << " space: " << space << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
static Gfx::SeDescriptorType getTypeFromKind(slang::TypeReflection::Kind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case slang::TypeReflection::Kind::ConstantBuffer:
|
||||
case slang::TypeReflection::Kind::GenericTypeParameter:
|
||||
case slang::TypeReflection::Kind::ParameterBlock:
|
||||
return Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
case slang::TypeReflection::Kind::ShaderStorageBuffer:
|
||||
return Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
case slang::TypeReflection::Kind::TextureBuffer:
|
||||
return Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
||||
case slang::TypeReflection::Kind::SamplerState:
|
||||
return Gfx::SE_DESCRIPTOR_TYPE_SAMPLER;
|
||||
default:
|
||||
return Gfx::SE_DESCRIPTOR_TYPE_MAX_ENUM;
|
||||
}
|
||||
}*/
|
||||
|
||||
void Shader::create(const ShaderCreateInfo& createInfo)
|
||||
{
|
||||
entryPointName = createInfo.entryPoint;
|
||||
|
||||
@@ -130,7 +130,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType,
|
||||
region.imageSubresource.layerCount = 1;
|
||||
|
||||
region.imageOffset = {0, 0, 0};
|
||||
region.imageExtent = {sizeX, sizeX, sizeZ};
|
||||
region.imageExtent = {sizeX, sizeY, sizeZ};
|
||||
|
||||
vkCmdCopyBufferToImage(cmdBufferManager->getCommands()->getHandle(),
|
||||
staging->getHandle(), image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
|
||||
@@ -251,10 +251,11 @@ void TextureHandle::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
||||
dstStage = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
|
||||
dstManager = graphics->getGraphicsCommands();
|
||||
}
|
||||
|
||||
VkCommandBuffer sourceCmd = sourceManager->getCommands()->getHandle();
|
||||
VkCommandBuffer destCmd = dstManager->getCommands()->getHandle();
|
||||
vkCmdPipelineBarrier(sourceCmd, srcStage, dstStage, 0, 0, nullptr, 0, nullptr, 1, &imageBarrier);
|
||||
vkCmdPipelineBarrier(destCmd, srcStage, dstStage, 0, 0, nullptr, 0, nullptr, 1, &imageBarrier);
|
||||
vkCmdPipelineBarrier(sourceCmd, srcStage, srcStage, 0, 0, nullptr, 0, nullptr, 1, &imageBarrier);
|
||||
vkCmdPipelineBarrier(destCmd, dstStage, dstStage, 0, 0, nullptr, 0, nullptr, 1, &imageBarrier);
|
||||
currentOwner = newOwner;
|
||||
sourceManager->submitCommands();
|
||||
}
|
||||
|
||||
@@ -162,8 +162,19 @@ void Window::advanceBackBuffer()
|
||||
imageAcquiredSemaphore = imageAcquired[semaphoreIndex];
|
||||
currentImageIndex = imageIndex;
|
||||
|
||||
backBufferImages[currentImageIndex]->changeLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
PCmdBuffer cmdBuffer = graphics->getGraphicsCommands()->getCommands();
|
||||
backBufferImages[currentImageIndex]->changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
VkClearColorValue clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
VkImageSubresourceRange range = init::ImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
vkCmdClearColorImage(
|
||||
cmdBuffer->getHandle(),
|
||||
backBufferImages[currentImageIndex]->getHandle(),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
&clearColor,
|
||||
1,
|
||||
&range);
|
||||
|
||||
backBufferImages[currentImageIndex]->changeLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
graphics->getGraphicsCommands()->getCommands()->addWaitSemaphore(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, imageAcquiredSemaphore);
|
||||
graphics->getGraphicsCommands()->submitCommands();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user