Basic UI quad, yay

This commit is contained in:
Dynamitos
2021-09-23 10:10:39 +02:00
parent df977110d3
commit 632d120f6d
51 changed files with 579 additions and 187 deletions
+7 -2
View File
@@ -4,6 +4,7 @@
"files.associations": {
"*.h": "cpp",
"*.ush": "hlsl",
"*.pl": "prolog",
"xstring": "cpp",
"list": "cpp",
"xhash": "cpp",
@@ -108,7 +109,10 @@
"coroutine": "cpp",
"*.tcc": "cpp",
"stop_token": "cpp",
"span": "cpp"
"span": "cpp",
"charconv": "cpp",
"format": "cpp",
"semaphore": "cpp"
},
"cmake.skipConfigureIfCachePresent": false,
"cmake.configureArgs": [
@@ -118,5 +122,6 @@
"C_Cpp.default.intelliSenseMode": "msvc-x64",
"files.watcherExclude": {
"**/target": true
}
},
"C_Cpp.errorSquiggles": "Disabled"
}
+2
View File
@@ -40,6 +40,8 @@ list (APPEND EXTRA_CMAKE_ARGS
#-----------------KTX----------------------------
list(APPEND DEPENDENCIES ktx)
find_program(BASH_EXECUTABLE git-bash)
add_subdirectory(${KTX_ROOT} ${KTX_ROOT})
#--------------------JSON------------------
+1 -1
+31
View File
@@ -0,0 +1,31 @@
struct VertexStageOutput
{
float4 position : SV_Position;
float2 uvCoords : TEXCOORD;
};
[shader("vertex")]
VertexStageOutput vertexMain(uint vertexId : SV_VertexID)
{
float2 coordinates[4] = {
float2(0, 0),
float2(0, 1),
float2(1, 0),
float2(1, 1)
};
VertexStageOutput output;
output.uvCoords = coordinates[vertexId];
output.position = float4(output.uvCoords * 2 - 1, 1, 1);
output.position.y = -output.position.y;
return output;
}
[shader("fragment")]
float4 fragmentMain(
float4 position : SV_Position,
float2 uvCoords : TEXCOORD
) : SV_Target
{
return float4(0, 1, 0, 1);
}
+1 -1
View File
@@ -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;
+31 -3
View File
@@ -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;
};
-38
View File
@@ -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
{
+2 -4
View File
@@ -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");
}
+1 -2
View File
@@ -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)
{
}
+5 -1
View File
@@ -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
+91
View File
@@ -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);
}
+33
View File
@@ -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
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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;
+4 -3
View File
@@ -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, &region);
@@ -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();
}
+12 -1
View File
@@ -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();
}
+1 -1
View File
@@ -27,7 +27,7 @@ Scene::Scene(Gfx::PGraphics graphics)
lightEnv.pointLights[i].positionWS = Vector4(frand() * 100-50, frand(), frand() * 100-50, 1);
}
lightEnv.numPointLights = 16;
lightEnv.pointLights[0].colorRange = Vector4(1, 0, 0, 100);
lightEnv.pointLights[0].colorRange = Vector4(1, 1, 1, 1000);
lightEnv.pointLights[0].positionWS = Vector4(0, 10, 0, 1);
}
+8 -4
View File
@@ -1,8 +1,12 @@
target_sources(SeeleEngine
PRIVATE
Element.h
Element.cpp
HorizontalLayout.h
HorizontalLayout.cpp
Layout.h
Layout.cpp
RenderHierarchy.h
RenderHierarchy.cpp
UIRenderPath.h
UIRenderPath.cpp)
VerticalLayout.h
VerticalLayout.cpp)
add_subdirectory(Elements/)
-27
View File
@@ -1,27 +0,0 @@
#pragma once
#include "MinimalEngine.h"
namespace Seele
{
namespace UI
{
//Element defines any part of the UI
DECLARE_REF(Element)
class Element
{
public:
Element();
virtual ~Element();
void addElement(PElement element);
const Array<PElement> getChildren() const;
void clear();
void remove(PElement element);
void setEnabled(bool newEnabled);
bool isEnabled() const;
protected:
bool enabled;
Array<PElement> children;
};
DEFINE_REF(Element)
} // namespace UI
} // namespace Seele
+4
View File
@@ -0,0 +1,4 @@
target_sources(SeeleEngine
PRIVATE
Element.h
Element.cpp)
@@ -11,12 +11,12 @@ Element::~Element()
{
}
void Element::addElement(PElement element)
void Element::addChild(PElement element)
{
children.add(element);
children.add(element);
}
const Array<PElement> Element::getChildren() const
const Array<PElement> Element::getChildren()
{
return children;
}
@@ -39,4 +39,14 @@ void Element::setEnabled(bool newEnabled)
bool Element::isEnabled() const
{
return enabled;
}
Rect& Element::getBoundingBox()
{
return boundingBox;
}
const Rect Element::getBoundingBox() const
{
return boundingBox;
}
+40
View File
@@ -0,0 +1,40 @@
#pragma once
#include "MinimalEngine.h"
namespace Seele
{
namespace UI
{
//Element defines any part of the UI
DECLARE_REF(Element)
class Element
{
public:
Element();
virtual ~Element();
void setParent(PElement element);
PElement getParent() const;
void addChild(PElement element);
const Array<PElement> getChildren();
void clear();
void remove(PElement element);
void setEnabled(bool newEnabled);
bool isEnabled() const;
// maybe not the healthiest inteface
// non-const version
Rect& getBoundingBox();
// The bounding box describes the relative size of any Element
// relative to the total view, meaning a bounding box of (0,0), (1,1)
// would take up the entire view
const Rect getBoundingBox() const;
protected:
Rect boundingBox;
bool enabled;
PElement parent;
Array<PElement> children;
friend class Layout;
friend class RenderElement;
};
DEFINE_REF(Element)
} // namespace UI
} // namespace Seele
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#include "Element.h"
namespace Seele
{
namespace UI
{
class Panel : Element
{
public:
Panel();
virtual ~Panel();
};
} // namespace UI
} // namespace Seele
+33
View File
@@ -0,0 +1,33 @@
#include "HorizontalLayout.h"
using namespace Seele;
using namespace Seele::UI;
HorizontalLayout::HorizontalLayout(PElement element)
: Layout(element)
{
}
HorizontalLayout::~HorizontalLayout()
{
}
void HorizontalLayout::apply()
{
Array<PElement> children = element->getChildren();
const Rect parent = element->getBoundingBox();
float xOffset = parent.offset.x;
float yOffset = parent.offset.y;
float xSize = parent.size.x / children.size();
float ySize = parent.size.y;
for(uint32 index = 0; index < children.size(); ++index)
{
Rect& child = children[index]->getBoundingBox();
child.offset.x = xOffset + (index * xSize);
child.offset.y = yOffset;
child.size.x = xSize;
child.size.y = ySize;
}
}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include "Layout.h"
namespace Seele
{
namespace UI
{
class HorizontalLayout : Layout
{
public:
HorizontalLayout(PElement element);
~HorizontalLayout();
virtual void apply() override;
private:
};
} // namespace UI
} // namespace Seele
+14
View File
@@ -0,0 +1,14 @@
#include "Layout.h"
using namespace Seele;
using namespace Seele::UI;
Layout::Layout(PElement element)
: element(element)
{
}
Layout::~Layout()
{
}
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include "Elements/Element.h"
namespace Seele
{
namespace UI
{
class Layout
{
public:
Layout(PElement element);
virtual ~Layout();
virtual void apply() = 0;
protected:
PElement element;
};
} // namespace UI
} // namespace Seele
+24
View File
@@ -0,0 +1,24 @@
#include "RenderHierarchy.h"
using namespace Seele;
using namespace Seele::UI;
RenderElement::RenderElement()
{
}
RenderElement::~RenderElement()
{
}
RenderHierarchy::RenderHierarchy()
{
}
RenderHierarchy::~RenderHierarchy()
{
}
+16 -2
View File
@@ -1,15 +1,29 @@
#pragma once
#include "Elements/Element.h"
namespace Seele
{
namespace UI
{
DECLARE_NAME_REF(Gfx, RenderCommand);
class RenderElement
{
public:
RenderElement();
virtual ~RenderElement();
private:
PElement referencedElement;
Gfx::PRenderCommand renderCommand;
friend class RenderHierarchy;
};
class RenderHierarchy
{
public:
RenderHierarchy();
~RenderHierarchy();
private:
// List of all drawable elements in draw order
Array<RenderElement> drawElements;
};
} // namespace UI
} // namespace Seele
View File
-20
View File
@@ -1,20 +0,0 @@
#pragma once
#include "Window/RenderPath.h"
#include "Element.h"
namespace Seele
{
class UIRenderPath : public RenderPath
{
public:
UIRenderPath();
virtual ~UIRenderPath();
virtual void beginFrame();
virtual void render();
virtual void endFrame();
private:
Array<UI::PElement> rootElements;
};
DEFINE_REF(UIRenderPath);
} // namespace Seele
+33
View File
@@ -0,0 +1,33 @@
#include "VerticalLayout.h"
using namespace Seele;
using namespace Seele::UI;
VerticalLayout::VerticalLayout(PElement element)
: Layout(element)
{
}
VerticalLayout::~VerticalLayout()
{
}
void VerticalLayout::apply()
{
Array<PElement> children = element->getChildren();
const Rect parent = element->getBoundingBox();
float xOffset = parent.offset.x;
float yOffset = parent.offset.y;
float xSize = parent.size.x;
float ySize = parent.size.y / children.size();
for(uint32 index = 0; index < children.size(); ++index)
{
Rect& child = children[index]->getBoundingBox();
child.offset.x = xOffset;
child.offset.y = yOffset + (index * ySize);
child.size.x = xSize;
child.size.y = ySize;
}
}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include "Layout.h"
namespace Seele
{
namespace UI
{
class VerticalLayout : Layout
{
public:
VerticalLayout(PElement element);
~VerticalLayout();
virtual void apply() override;
private:
};
} // namespace UI
} // namespace Seele
+34 -2
View File
@@ -1,9 +1,16 @@
#include "InspectorView.h"
#include "Window.h"
using namespace Seele;
InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo)
: View(graphics, window, createInfo)
{
renderGraph = new RenderGraph();
Gfx::PRenderTargetAttachment attachment = new Gfx::SwapchainAttachment(window->getGfxHandle());
uiPass = new UIPass(renderGraph, graphics, viewport, attachment);
renderGraph->addRenderPass(uiPass);
renderGraph->setup();
}
InspectorView::~InspectorView()
@@ -12,15 +19,40 @@ InspectorView::~InspectorView()
void InspectorView::beginFrame()
{
uiPass->beginFrame();
}
void InspectorView::render()
{
uiPass->render();
}
void InspectorView::endFrame()
{
uiPass->endFrame();
}
void InspectorView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier)
{
}
void InspectorView::mouseMoveCallback(double xPos, double yPos)
{
}
void InspectorView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier)
{
}
void InspectorView::scrollCallback(double xOffset, double yOffset)
{
}
void InspectorView::fileCallback(int count, const char** paths)
{
}
+17 -3
View File
@@ -1,9 +1,11 @@
#pragma once
#include "View.h"
#include "UI/UIRenderPath.h"
#include "Graphics/RenderPass/RenderGraph.h"
#include "Graphics/RenderPass/UIPass.h"
namespace Seele
{
DECLARE_REF(Actor)
class InspectorView : public View
{
public:
@@ -12,7 +14,19 @@ public:
virtual void beginFrame();
virtual void render();
virtual void endFrame();
private:
void selectActor();
protected:
Array<UI::PElement> rootElements;
PUIPass uiPass;
PActor selectedActor;
PRenderGraph renderGraph;
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) override;
virtual void mouseMoveCallback(double xPos, double yPos) override;
virtual void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) override;
virtual void scrollCallback(double xOffset, double yOffset) override;
virtual void fileCallback(int count, const char** paths) override;
};
DEFINE_REF(InspectorView)
} // namespace Seele
-1
View File
@@ -25,6 +25,5 @@ protected:
PDepthPrepass depthPrepass;
PLightCullingPass lightCullingPass;
PBasePass basePass;
};
} // namespace Seele
+1 -1
View File
@@ -3,7 +3,7 @@
namespace Seele
{
DECLARE_REF(Window)
// A view is a part of the window, which can be anything from a viewport to an editor
// A view is a part of the window, which can be anything from a viewport to an inspector
class View
{
public:
+10 -1
View File
@@ -1,5 +1,6 @@
#include "Graphics/RenderCore.h"
#include "Window/SceneView.h"
#include "Window/InspectorView.h"
#include "Asset/AssetRegistry.h"
#include "Fibers/Fibers.h"
#include <queue>
@@ -19,12 +20,20 @@ int main()
mainWindowInfo.pixelFormat = Gfx::SE_FORMAT_B8G8R8A8_UNORM;
auto window = core.getWindowManager()->addWindow(mainWindowInfo);
ViewportCreateInfo sceneViewInfo;
sceneViewInfo.sizeX = 1280;
sceneViewInfo.sizeX = 640;
sceneViewInfo.sizeY = 720;
sceneViewInfo.offsetX = 0;
sceneViewInfo.offsetY = 0;
PSceneView sceneView = new SceneView(core.getWindowManager()->getGraphics(), window, sceneViewInfo);
window->addView(sceneView);
ViewportCreateInfo inspectorViewInfo;
inspectorViewInfo.sizeX = 640;
inspectorViewInfo.sizeY = 720;
inspectorViewInfo.offsetX = 640;
inspectorViewInfo.offsetY = 0;
PInspectorView inspectorView = new InspectorView(core.getWindowManager()->getGraphics(), window, inspectorViewInfo);
window->addView(inspectorView);
sceneView->setFocused();
AssetRegistry::init("D:\\Private\\Programming\\C++\\TestSeeleProject\\");
AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Ely\\Ely.fbx");