Irradiance works
This commit is contained in:
@@ -16,12 +16,14 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
||||
Array<VkImageView> attachments;
|
||||
uint32 width = 0;
|
||||
uint32 height = 0;
|
||||
uint32 layers = 0;
|
||||
for (auto inputAttachment : layout.inputAttachments) {
|
||||
PTextureBase vkInputAttachment = inputAttachment.getTexture().cast<TextureBase>();
|
||||
attachments.add(vkInputAttachment->getView());
|
||||
description.inputAttachments[description.numInputAttachments++] = vkInputAttachment->getView();
|
||||
width = std::max(width, vkInputAttachment->getWidth());
|
||||
height = std::max(height, vkInputAttachment->getHeight());
|
||||
layers = std::max(layers, vkInputAttachment->getNumLayers());
|
||||
}
|
||||
for (auto colorAttachment : layout.colorAttachments) {
|
||||
PTextureBase vkColorAttachment = colorAttachment.getTexture().cast<TextureBase>();
|
||||
@@ -29,6 +31,7 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
||||
description.colorAttachments[description.numColorAttachments++] = vkColorAttachment->getView();
|
||||
width = std::max(width, vkColorAttachment->getWidth());
|
||||
height = std::max(height, vkColorAttachment->getHeight());
|
||||
layers = std::max(layers, vkColorAttachment->getNumLayers());
|
||||
}
|
||||
for (auto resolveAttachment : layout.resolveAttachments) {
|
||||
PTextureBase vkResolveAttachment = resolveAttachment.getTexture().cast<TextureBase>();
|
||||
@@ -36,6 +39,7 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
||||
description.resolveAttachments[description.numResolveAttachments++] = vkResolveAttachment->getView();
|
||||
width = std::max(width, vkResolveAttachment->getWidth());
|
||||
height = std::max(height, vkResolveAttachment->getHeight());
|
||||
layers = std::max(layers, vkResolveAttachment->getNumLayers());
|
||||
}
|
||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||
PTextureBase vkDepthAttachment = layout.depthAttachment.getTexture().cast<TextureBase>();
|
||||
@@ -43,6 +47,7 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
||||
description.depthAttachment = vkDepthAttachment->getView();
|
||||
width = std::max(width, vkDepthAttachment->getWidth());
|
||||
height = std::max(height, vkDepthAttachment->getHeight());
|
||||
layers = std::max(layers, vkDepthAttachment->getNumLayers());
|
||||
}
|
||||
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
||||
PTextureBase vkDepthAttachment = layout.depthResolveAttachment.getTexture().cast<TextureBase>();
|
||||
@@ -50,6 +55,7 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
||||
description.depthResolveAttachment = vkDepthAttachment->getView();
|
||||
width = std::max(width, vkDepthAttachment->getWidth());
|
||||
height = std::max(height, vkDepthAttachment->getHeight());
|
||||
layers = std::max(layers, vkDepthAttachment->getNumLayers());
|
||||
}
|
||||
VkFramebufferCreateInfo createInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::Vulkan;
|
||||
|
||||
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> _dependencies,
|
||||
URect viewport, std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks)
|
||||
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> _dependencies, URect viewport,
|
||||
std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks)
|
||||
: Gfx::RenderPass(std::move(_layout), std::move(_dependencies)), graphics(graphics) {
|
||||
renderArea.extent.width = viewport.size.x;
|
||||
renderArea.extent.height = viewport.size.y;
|
||||
@@ -166,6 +166,7 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
.pNext = layout.depthResolveAttachment.getTexture() != nullptr ? &depthResolve : nullptr,
|
||||
.flags = 0,
|
||||
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
.viewMask = viewMasks[0],
|
||||
.inputAttachmentCount = (uint32)inputRefs.size(),
|
||||
.pInputAttachments = inputRefs.data(),
|
||||
.colorAttachmentCount = (uint32)colorRefs.size(),
|
||||
@@ -196,19 +197,9 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
.pSubpasses = &subPassDesc,
|
||||
.dependencyCount = (uint32)dep.size(),
|
||||
.pDependencies = dep.data(),
|
||||
.correlatedViewMaskCount = (uint32)correlationMasks.size(),
|
||||
.pCorrelatedViewMasks = correlationMasks.data(),
|
||||
};
|
||||
VkRenderPassMultiviewCreateInfo multiViewInfo;
|
||||
if (!viewMasks.empty()) {
|
||||
multiViewInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.subpassCount = 1,
|
||||
.pViewMasks = viewMasks.data(),
|
||||
.correlationMaskCount = (uint32)correlationMasks.size(),
|
||||
.pCorrelationMasks = correlationMasks.data(),
|
||||
};
|
||||
info.pNext = &multiViewInfo;
|
||||
}
|
||||
VK_CHECK(vkCreateRenderPass2(graphics->getDevice(), &info, nullptr, &renderPass));
|
||||
VkDebugUtilsObjectNameInfoEXT nameInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
|
||||
|
||||
@@ -31,7 +31,7 @@ VkImageAspectFlags getAspectFromFormat(Gfx::SeFormat format) {
|
||||
TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage)
|
||||
: CommandBoundResource(graphics, createInfo.name), image(existingImage), imageView(VK_NULL_HANDLE), allocation(nullptr),
|
||||
owner(createInfo.sourceData.owner), width(createInfo.width), height(createInfo.height), depth(createInfo.depth),
|
||||
arrayCount(createInfo.elements), layerCount(createInfo.layers), mipLevels(1), samples(createInfo.samples), format(createInfo.format),
|
||||
layerCount(createInfo.elements), mipLevels(1), samples(createInfo.samples), format(createInfo.format),
|
||||
usage(createInfo.usage), layout(Gfx::SE_IMAGE_LAYOUT_UNDEFINED), aspect(getAspectFromFormat(createInfo.format)), ownsImage(false) {
|
||||
if (createInfo.useMip) {
|
||||
mipLevels = static_cast<uint32_t>(std::floor(std::log2(std::max(width, height)))) + 1;
|
||||
@@ -55,7 +55,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
||||
case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
|
||||
type = VK_IMAGE_TYPE_2D;
|
||||
flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
|
||||
layerCount = 6 * arrayCount;
|
||||
layerCount = 6 * layerCount;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -76,7 +76,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
||||
.depth = depth,
|
||||
},
|
||||
.mipLevels = mipLevels,
|
||||
.arrayLayers = arrayCount * layerCount,
|
||||
.arrayLayers = layerCount,
|
||||
.samples = (VkSampleCountFlagBits)samples,
|
||||
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = usage,
|
||||
@@ -129,7 +129,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
||||
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.mipLevel = 0,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = arrayCount * layerCount,
|
||||
.layerCount = layerCount,
|
||||
},
|
||||
.imageOffset =
|
||||
{
|
||||
@@ -163,7 +163,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
||||
{
|
||||
.aspectMask = aspect,
|
||||
.levelCount = mipLevels,
|
||||
.layerCount = layerCount * arrayCount,
|
||||
.layerCount = layerCount,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -195,7 +195,7 @@ void TextureHandle::pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlag
|
||||
.baseMipLevel = 0,
|
||||
.levelCount = mipLevels,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = layerCount * arrayCount,
|
||||
.layerCount = layerCount,
|
||||
},
|
||||
};
|
||||
PCommand command = graphics->getQueueCommands(owner)->getCommands();
|
||||
@@ -223,7 +223,7 @@ void TextureHandle::transferOwnership(Gfx::QueueType newOwner) {
|
||||
.baseMipLevel = 0,
|
||||
.levelCount = mipLevels,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = arrayCount,
|
||||
.layerCount = layerCount,
|
||||
},
|
||||
};
|
||||
PCommandPool sourcePool = graphics->getQueueCommands(owner);
|
||||
|
||||
@@ -25,7 +25,6 @@ class TextureHandle : public CommandBoundResource {
|
||||
uint32 width;
|
||||
uint32 height;
|
||||
uint32 depth;
|
||||
uint32 arrayCount;
|
||||
uint32 layerCount;
|
||||
uint32 mipLevels;
|
||||
uint32 samples;
|
||||
@@ -48,6 +47,7 @@ class TextureBase {
|
||||
uint32 getWidth() const { return handle->width; }
|
||||
uint32 getHeight() const { return handle->height; }
|
||||
uint32 getDepth() const { return handle->depth; }
|
||||
uint32 getNumLayers() const { return handle->layerCount; }
|
||||
PTextureHandle getHandle() const { return handle; }
|
||||
VkImage getImage() const { return handle->image; };
|
||||
VkImageView getView() const { return handle->imageView; };
|
||||
|
||||
@@ -276,7 +276,6 @@ void Window::createSwapChain() {
|
||||
.width = extent.width,
|
||||
.height = extent.height,
|
||||
.depth = 1,
|
||||
.layers = 1,
|
||||
.elements = 1,
|
||||
.samples = 1,
|
||||
.usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | Gfx::SE_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
|
||||
Reference in New Issue
Block a user