New game interface

This commit is contained in:
Dynamitos
2023-02-01 22:13:04 +01:00
parent 0dce84459e
commit 9e1e4076f0
91 changed files with 268 additions and 21014 deletions
+2
View File
@@ -547,6 +547,8 @@ public:
virtual uint32 getMipLevels() const = 0;
virtual void changeLayout(SeImageLayout newLayout) = 0;
virtual class Texture2D* getTexture2D() { return nullptr; }
virtual class Texture3D* getTexture3D() { return nullptr; }
virtual class TextureCube* getTextureCube() { return nullptr; }
virtual void* getNativeHandle() { return nullptr; }
protected:
// Inherited via QueueOwnedResource
@@ -8,58 +8,58 @@ SkyboxRenderPass::SkyboxRenderPass(Gfx::PGraphics graphics)
{
Array<Vector> vertices = {
// Back
Vector(-1, -1, -1),
Vector(1, -1, -1),
Vector(-1, 1, -1),
Vector(-512, -512, 512),
Vector(-512, 512, 512),
Vector( 512, -512, 512),
Vector(1, -1, -1),
Vector(-1, 1, -1),
Vector(1, 1, -1),
Vector( 512, -512, 512),
Vector(-512, 512, 512),
Vector( 512, 512, 512),
// Front
Vector(1, -1, 1),
Vector(-1, 1, 1),
Vector(-1, -1, 1),
Vector( 512, -512, -512),
Vector( 512, 512, -512),
Vector(-512, -512, -512),
Vector(-1, 1, 1),
Vector(1, 1, 1),
Vector(1, -1, 1),
Vector(-512, -512, -512),
Vector( 512, 512, -512),
Vector(-512, 512, -512),
// Top
Vector(-1, -1, -1),
Vector(1, -1, -1),
Vector(1, -1, 1),
Vector(-512, -512, -512),
Vector(-512, -512, 512),
Vector( 512, -512, -512),
Vector(1, -1, -1),
Vector(1, -1, 1),
Vector(1, -1, 1),
Vector( 512, -512, -512),
Vector(-512, -512, 512),
Vector( 512, -512, 512),
// Bottom
Vector(-1, 1, -1),
Vector(-1, 1, 1),
Vector(1, 1, -1),
Vector(-512, 512, 512),
Vector(-512, 512, -512),
Vector( 512, 512, 512),
Vector(1, 1, -1),
Vector(-1, 1, 1),
Vector(1, 1, 1),
Vector( 512, 512, 512),
Vector(-512, 512, -512),
Vector( 512, 512, -512),
// Left
Vector(-1, -1, -1),
Vector(-1, -1, 1),
Vector(-1, 1, -1),
Vector(-512, -512, -512),
Vector(-512, 512, -512),
Vector(-512, -512, 512),
Vector(-1, 1, -1),
Vector(-1, -1, 1),
Vector(-1, 1, 1),
Vector(-512, -512, 512),
Vector(-512, 512, -512),
Vector(-512, 512, 512),
// Right
Vector(1, -1, 1),
Vector(1, 1, -1),
Vector(1, -1, -1),
Vector( 512, -512, 512),
Vector( 512, 512, 512),
Vector( 512, -512, -512),
Vector(1, -1, 1),
Vector(1, 1, 1),
Vector(1, 1, -1),
Vector( 512, -512, -512),
Vector( 512, 512, 512),
Vector( 512, 512, -512),
};
VertexBufferCreateInfo vertexBufferInfo = {
@@ -93,7 +93,7 @@ void SkyboxRenderPass::beginFrame(const Component::Camera& cam)
descriptorSet->updateBuffer(0, viewParamsBuffer);
descriptorSet->updateTexture(1, passData.skybox.day);
descriptorSet->updateTexture(2, passData.skybox.night);
descriptorSet->updateSampler(3, passData.skybox.sampler);
descriptorSet->updateSampler(3, skyboxSampler);
descriptorSet->writeChanges();
}
@@ -105,8 +105,8 @@ void SkyboxRenderPass::render()
renderCommand->bindPipeline(pipeline);
renderCommand->bindDescriptor(descriptorSet);
renderCommand->bindVertexBuffer({ VertexInputStream(0, 0, cubeBuffer) });
renderCommand->pushConstants(pipelineLayout, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, sizeof(Vector), &passData.skybox.fogColor);
renderCommand->pushConstants(pipelineLayout, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, sizeof(Vector), sizeof(float), &passData.skybox.blendFactor);
renderCommand->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(Vector), &passData.skybox.fogColor);
renderCommand->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, sizeof(Vector), sizeof(float), &passData.skybox.blendFactor);
renderCommand->draw(36, 1, 0, 0);
graphics->executeCommands(Array{ renderCommand });
graphics->endRenderPass();
@@ -138,17 +138,14 @@ void SkyboxRenderPass::publishOutputs()
pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
pipelineLayout->addPushConstants(Gfx::SePushConstantRange{
.stageFlags = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
.stageFlags = Gfx::SE_SHADER_STAGE_FRAGMENT_BIT,
.offset = 0,
.size = sizeof(Vector),
});
pipelineLayout->addPushConstants(Gfx::SePushConstantRange{
.stageFlags = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
.offset = sizeof(Vector),
.size = sizeof(float),
.size = sizeof(Vector4),
});
pipelineLayout->create();
skyboxSampler = graphics->createSamplerState({});
}
void SkyboxRenderPass::createRenderPass()
@@ -29,6 +29,7 @@ private:
Gfx::PDescriptorSet descriptorSet;
Gfx::PPipelineLayout pipelineLayout;
Gfx::PGraphicsPipeline pipeline;
Gfx::PSamplerState skyboxSampler;
};
DEFINE_REF(SkyboxRenderPass)
} // namespace Seele
@@ -258,6 +258,7 @@ private:
uint32 sizeY;
uint32 sizeZ;
uint32 arrayCount;
uint32 layerCount;
uint32 mipLevels;
uint32 samples;
Gfx::SeFormat format;
+15 -4
View File
@@ -37,6 +37,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType,
, sizeY(createInfo.height)
, sizeZ(createInfo.depth)
, arrayCount(createInfo.bArray ? createInfo.arrayLayers : 1)
, layerCount(1)
, mipLevels(createInfo.mipLevels)
, samples(createInfo.samples)
, format(createInfo.format)
@@ -53,10 +54,8 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType,
info.extent.width = sizeX;
info.extent.height = sizeY;
info.extent.depth = sizeZ;
info.arrayLayers = arrayCount;
info.format = cast(format);
uint32 layerCount = 1;
switch (viewType)
{
case VK_IMAGE_VIEW_TYPE_1D:
@@ -72,6 +71,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType,
break;
case VK_IMAGE_VIEW_TYPE_CUBE:
case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
info.flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
info.imageType = VK_IMAGE_TYPE_2D;
layerCount = 6 * arrayCount;
break;
@@ -127,7 +127,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType,
region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
region.imageSubresource.mipLevel = 0;
region.imageSubresource.baseArrayLayer = 0;
region.imageSubresource.layerCount = 1;
region.imageSubresource.layerCount = layerCount;
region.imageOffset = {0, 0, 0};
region.imageExtent = {sizeX, sizeY, sizeZ};
@@ -153,7 +153,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType,
viewInfo.viewType = viewType;
viewInfo.image = image;
viewInfo.format = cast(format);
viewInfo.subresourceRange.layerCount = (viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY || viewType == VK_IMAGE_VIEW_TYPE_CUBE) ? 6 : 1;
viewInfo.subresourceRange.layerCount = layerCount;
viewInfo.subresourceRange.levelCount = mipLevels;
VK_CHECK(vkCreateImageView(graphics->getDevice(), &viewInfo, nullptr, &defaultView));
@@ -181,6 +181,16 @@ TextureHandle* TextureBase::cast(Gfx::PTexture texture)
PTexture2D texture2D = texture.cast<Texture2D>();
return texture2D->textureHandle;
}
if(texture->getTexture3D() != nullptr)
{
PTexture3D texture3D = texture.cast<Texture3D>();
return texture3D->textureHandle;
}
if(texture->getTextureCube() != nullptr)
{
PTextureCube textureCube = texture.cast<TextureCube>();
return textureCube->textureHandle;
}
return nullptr;
}
@@ -193,6 +203,7 @@ void TextureHandle::changeLayout(Gfx::SeImageLayout newLayout)
cast(newLayout));
barrier.subresourceRange =
init::ImageSubresourceRange(aspect);
barrier.subresourceRange.layerCount = layerCount;
PCommandBufferManager cmdManager = graphics->getQueueCommands(currentOwner);
vkCmdPipelineBarrier(cmdManager->getCommands()->getHandle(),
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,