Initial environment loading (not working)
This commit is contained in:
@@ -312,63 +312,7 @@ void DescriptorSet::updateSampler(const std::string& mappingName, uint32 index,
|
||||
boundResources[binding][index] = vulkanSampler->getHandle();
|
||||
}
|
||||
|
||||
void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTexture2D texture) {
|
||||
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
||||
const auto& map = owner->getLayout()->mappings[mappingName];
|
||||
uint32 binding = map.binding;
|
||||
if (boundResources[binding][index] == vulkanTexture->getHandle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// It is assumed that the image is in the correct layout
|
||||
imageInfos.add(VkDescriptorImageInfo{
|
||||
.sampler = VK_NULL_HANDLE,
|
||||
.imageView = vulkanTexture->getView(),
|
||||
.imageLayout = cast(vulkanTexture->getLayout()),
|
||||
});
|
||||
writeDescriptors.add(VkWriteDescriptorSet{
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.pNext = nullptr,
|
||||
.dstSet = setHandle,
|
||||
.dstBinding = binding,
|
||||
.dstArrayElement = index,
|
||||
.descriptorCount = 1,
|
||||
.descriptorType = map.type,
|
||||
.pImageInfo = &imageInfos.back(),
|
||||
});
|
||||
|
||||
boundResources[binding][index] = vulkanTexture->getHandle();
|
||||
}
|
||||
|
||||
void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTexture3D texture) {
|
||||
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
||||
const auto& map = owner->getLayout()->mappings[mappingName];
|
||||
uint32 binding = map.binding;
|
||||
if (boundResources[binding][index] == vulkanTexture->getHandle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// It is assumed that the image is in the correct layout
|
||||
imageInfos.add(VkDescriptorImageInfo{
|
||||
.sampler = VK_NULL_HANDLE,
|
||||
.imageView = vulkanTexture->getView(),
|
||||
.imageLayout = cast(vulkanTexture->getLayout()),
|
||||
});
|
||||
writeDescriptors.add(VkWriteDescriptorSet{
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.pNext = nullptr,
|
||||
.dstSet = setHandle,
|
||||
.dstBinding = binding,
|
||||
.dstArrayElement = index,
|
||||
.descriptorCount = 1,
|
||||
.descriptorType = map.type,
|
||||
.pImageInfo = &imageInfos.back(),
|
||||
});
|
||||
|
||||
boundResources[binding][index] = vulkanTexture->getHandle();
|
||||
}
|
||||
|
||||
void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTextureCube texture) {
|
||||
void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTexture texture) {
|
||||
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
||||
const auto& map = owner->getLayout()->mappings[mappingName];
|
||||
uint32 binding = map.binding;
|
||||
|
||||
@@ -64,9 +64,7 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource {
|
||||
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer indexBuffer) override;
|
||||
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer indexBuffer) override;
|
||||
virtual void updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) override;
|
||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture2D texture) override;
|
||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture3D texture) override;
|
||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) override;
|
||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture texture) override;
|
||||
virtual void updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) override;
|
||||
|
||||
constexpr VkDescriptorSet getHandle() const { return setHandle; }
|
||||
|
||||
@@ -17,35 +17,35 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
||||
uint32 width = 0;
|
||||
uint32 height = 0;
|
||||
for (auto inputAttachment : layout.inputAttachments) {
|
||||
PTexture2D vkInputAttachment = inputAttachment.getTexture().cast<Texture2D>();
|
||||
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());
|
||||
}
|
||||
for (auto colorAttachment : layout.colorAttachments) {
|
||||
PTexture2D vkColorAttachment = colorAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase vkColorAttachment = colorAttachment.getTexture().cast<TextureBase>();
|
||||
attachments.add(vkColorAttachment->getView());
|
||||
description.colorAttachments[description.numColorAttachments++] = vkColorAttachment->getView();
|
||||
width = std::max(width, vkColorAttachment->getWidth());
|
||||
height = std::max(height, vkColorAttachment->getHeight());
|
||||
}
|
||||
for (auto resolveAttachment : layout.resolveAttachments) {
|
||||
PTexture2D vkResolveAttachment = resolveAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase vkResolveAttachment = resolveAttachment.getTexture().cast<TextureBase>();
|
||||
attachments.add(vkResolveAttachment->getView());
|
||||
description.resolveAttachments[description.numResolveAttachments++] = vkResolveAttachment->getView();
|
||||
width = std::max(width, vkResolveAttachment->getWidth());
|
||||
height = std::max(height, vkResolveAttachment->getHeight());
|
||||
}
|
||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||
PTexture2D vkDepthAttachment = layout.depthAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase vkDepthAttachment = layout.depthAttachment.getTexture().cast<TextureBase>();
|
||||
attachments.add(vkDepthAttachment->getView());
|
||||
description.depthAttachment = vkDepthAttachment->getView();
|
||||
width = std::max(width, vkDepthAttachment->getWidth());
|
||||
height = std::max(height, vkDepthAttachment->getHeight());
|
||||
}
|
||||
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
||||
PTexture2D vkDepthAttachment = layout.depthResolveAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase vkDepthAttachment = layout.depthResolveAttachment.getTexture().cast<TextureBase>();
|
||||
attachments.add(vkDepthAttachment->getView());
|
||||
description.depthResolveAttachment = vkDepthAttachment->getView();
|
||||
width = std::max(width, vkDepthAttachment->getWidth());
|
||||
|
||||
@@ -172,8 +172,9 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate
|
||||
}
|
||||
|
||||
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
||||
Gfx::PViewport renderArea, std::string name) {
|
||||
return new RenderPass(this, std::move(layout), std::move(dependencies), renderArea, name);
|
||||
URect renderArea, std::string name, Array<uint32> viewMasks,
|
||||
Array<uint32> correlationMasks) {
|
||||
return new RenderPass(this, std::move(layout), std::move(dependencies), renderArea, name, std::move(viewMasks), std::move(correlationMasks));
|
||||
}
|
||||
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) {
|
||||
PRenderPass rp = renderPass.cast<RenderPass>();
|
||||
@@ -824,6 +825,7 @@ void Graphics::pickPhysicalDevice() {
|
||||
.pNext = &features12,
|
||||
.storageBuffer16BitAccess = true,
|
||||
.uniformAndStorageBuffer16BitAccess = true,
|
||||
.multiview = true,
|
||||
};
|
||||
features = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
||||
@@ -950,6 +952,7 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
|
||||
initializer.deviceExtensions.add(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
|
||||
initializer.deviceExtensions.add(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
|
||||
}
|
||||
initializer.deviceExtensions.add(VK_KHR_MULTIVIEW_EXTENSION_NAME);
|
||||
#ifdef __APPLE__
|
||||
initializer.deviceExtensions.add("VK_KHR_portability_subset");
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,8 @@ class Graphics : public Gfx::Graphics {
|
||||
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
|
||||
|
||||
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
||||
Gfx::PViewport renderArea, std::string name) override;
|
||||
URect renderArea, std::string name, Array<uint32> viewMasks,
|
||||
Array<uint32> correlationMasks) override;
|
||||
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
|
||||
virtual void endRenderPass() override;
|
||||
virtual void waitDeviceIdle() override;
|
||||
|
||||
@@ -6,17 +6,16 @@
|
||||
#include "Resources.h"
|
||||
#include "Texture.h"
|
||||
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Vulkan;
|
||||
|
||||
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> _dependencies,
|
||||
Gfx::PViewport viewport, std::string name)
|
||||
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->getWidth();
|
||||
renderArea.extent.height = viewport->getHeight();
|
||||
renderArea.offset.x = viewport->getOffsetX();
|
||||
renderArea.offset.y = viewport->getOffsetY();
|
||||
renderArea.extent.width = viewport.size.x;
|
||||
renderArea.extent.height = viewport.size.y;
|
||||
renderArea.offset.x = viewport.offset.x;
|
||||
renderArea.offset.y = viewport.offset.y;
|
||||
subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
|
||||
Array<VkAttachmentDescription2> attachments;
|
||||
Array<VkAttachmentReference2> inputRefs;
|
||||
@@ -198,7 +197,18 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
.dependencyCount = (uint32)dep.size(),
|
||||
.pDependencies = dep.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,
|
||||
@@ -220,23 +230,23 @@ uint32 RenderPass::getFramebufferHash() {
|
||||
FramebufferDescription description;
|
||||
std::memset(&description, 0, sizeof(FramebufferDescription));
|
||||
for (auto& inputAttachment : layout.inputAttachments) {
|
||||
PTexture2D tex = inputAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase tex = inputAttachment.getTexture().cast<TextureBase>();
|
||||
description.inputAttachments[description.numInputAttachments++] = tex->getView();
|
||||
}
|
||||
for (auto& colorAttachment : layout.colorAttachments) {
|
||||
PTexture2D tex = colorAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase tex = colorAttachment.getTexture().cast<TextureBase>();
|
||||
description.colorAttachments[description.numColorAttachments++] = tex->getView();
|
||||
}
|
||||
for (auto& resolveAttachment : layout.resolveAttachments) {
|
||||
PTexture2D tex = resolveAttachment.getTexture().cast<Texture2D>();
|
||||
description.resolveAttachments[description.numResolveAttachments++] = tex->getView();
|
||||
PTextureBase tex = resolveAttachment.getTexture().cast<TextureBase>();
|
||||
description.resolveAttachments[description.numResolveAttachments++] = tex->getView();
|
||||
}
|
||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||
PTexture2D tex = layout.depthAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase tex = layout.depthAttachment.getTexture().cast<TextureBase>();
|
||||
description.depthAttachment = tex->getView();
|
||||
}
|
||||
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
||||
PTexture2D tex = layout.depthResolveAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase tex = layout.depthResolveAttachment.getTexture().cast<TextureBase>();
|
||||
description.depthResolveAttachment = tex->getView();
|
||||
}
|
||||
return CRC::Calculate(&description, sizeof(FramebufferDescription), CRC::CRC_32());
|
||||
@@ -244,23 +254,23 @@ uint32 RenderPass::getFramebufferHash() {
|
||||
|
||||
void RenderPass::endRenderPass() {
|
||||
for (auto& inputAttachment : layout.inputAttachments) {
|
||||
PTexture2D tex = inputAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase tex = inputAttachment.getTexture().cast<TextureBase>();
|
||||
tex->setLayout(inputAttachment.getFinalLayout());
|
||||
}
|
||||
for (auto& colorAttachment : layout.colorAttachments) {
|
||||
PTexture2D tex = colorAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase tex = colorAttachment.getTexture().cast<TextureBase>();
|
||||
tex->setLayout(colorAttachment.getFinalLayout());
|
||||
}
|
||||
for (auto& resolveAttachment : layout.resolveAttachments) {
|
||||
PTexture2D tex = resolveAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase tex = resolveAttachment.getTexture().cast<TextureBase>();
|
||||
tex->setLayout(resolveAttachment.getFinalLayout());
|
||||
}
|
||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||
PTexture2D tex = layout.depthAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase tex = layout.depthAttachment.getTexture().cast<TextureBase>();
|
||||
tex->setLayout(layout.depthAttachment.getFinalLayout());
|
||||
}
|
||||
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
||||
PTexture2D tex = layout.depthResolveAttachment.getTexture().cast<Texture2D>();
|
||||
PTextureBase tex = layout.depthResolveAttachment.getTexture().cast<TextureBase>();
|
||||
tex->setLayout(layout.depthResolveAttachment.getFinalLayout());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace Seele {
|
||||
namespace Vulkan {
|
||||
class RenderPass : public Gfx::RenderPass {
|
||||
public:
|
||||
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, Gfx::PViewport viewport, std::string name);
|
||||
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect viewport,
|
||||
std::string name, Array<uint32> viewMasks = {}, Array<uint32> correlationMasks = {});
|
||||
virtual ~RenderPass();
|
||||
uint32 getFramebufferHash();
|
||||
void endRenderPass();
|
||||
|
||||
@@ -29,10 +29,10 @@ VkImageAspectFlags getAspectFromFormat(Gfx::SeFormat format) {
|
||||
}
|
||||
|
||||
TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage)
|
||||
: CommandBoundResource(graphics, createInfo.name), image(existingImage), 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), usage(createInfo.usage),
|
||||
layout(Gfx::SE_IMAGE_LAYOUT_UNDEFINED), aspect(getAspectFromFormat(createInfo.format)), ownsImage(false) {
|
||||
: 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),
|
||||
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;
|
||||
}
|
||||
@@ -95,7 +95,8 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
||||
.pObjectName = name.c_str(),
|
||||
};
|
||||
vkSetDebugUtilsObjectNameEXT(graphics->getDevice(), &nameInfo);
|
||||
ownsImage = true;const DataSource& sourceData = createInfo.sourceData;
|
||||
ownsImage = true;
|
||||
const DataSource& sourceData = createInfo.sourceData;
|
||||
if (sourceData.size > 0) {
|
||||
changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_ACCESS_NONE, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
@@ -117,7 +118,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
||||
vmaMapMemory(graphics->getAllocator(), stagingAlloc->allocation, &data);
|
||||
std::memcpy(data, sourceData.data, sourceData.size);
|
||||
vmaUnmapMemory(graphics->getAllocator(), stagingAlloc->allocation);
|
||||
|
||||
|
||||
PCommandPool commandPool = graphics->getQueueCommands(owner);
|
||||
VkBufferImageCopy region = {
|
||||
.bufferOffset = 0,
|
||||
@@ -138,10 +139,10 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
||||
},
|
||||
.imageExtent = {.width = width, .height = height, .depth = depth},
|
||||
};
|
||||
|
||||
vkCmdCopyBufferToImage(commandPool->getCommands()->getHandle(), stagingAlloc->buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1, ®ion);
|
||||
|
||||
|
||||
vkCmdCopyBufferToImage(commandPool->getCommands()->getHandle(), stagingAlloc->buffer, image,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
|
||||
|
||||
commandPool->getCommands()->bindResource(PBufferAllocation(stagingAlloc));
|
||||
generateMipmaps();
|
||||
// When loading a texture from a file, we will almost always use it as a texture map for fragment shaders
|
||||
@@ -150,7 +151,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
||||
graphics->getDestructionManager()->queueResourceForDestruction(std::move(stagingAlloc));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VkImageViewCreateInfo viewInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
@@ -385,7 +386,10 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, const Tex
|
||||
: handle(new TextureHandle(graphics, viewType, createInfo, existingImage)), graphics(graphics),
|
||||
initialOwner(createInfo.sourceData.owner) {}
|
||||
|
||||
TextureBase::~TextureBase() { graphics->getDestructionManager()->queueResourceForDestruction(std::move(handle)); }
|
||||
TextureBase::~TextureBase() {
|
||||
graphics->getDestructionManager()->queueResourceForDestruction(std::move(handle));
|
||||
handle = nullptr;
|
||||
}
|
||||
|
||||
void TextureBase::pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
||||
VkPipelineStageFlags dstStage) {
|
||||
|
||||
@@ -6,15 +6,13 @@
|
||||
#include "Resources.h"
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
|
||||
namespace Seele {
|
||||
namespace Vulkan {
|
||||
class TextureHandle : public CommandBoundResource {
|
||||
public:
|
||||
TextureHandle(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage);
|
||||
virtual ~TextureHandle();
|
||||
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
||||
VkPipelineStageFlags dstStage);
|
||||
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
|
||||
void transferOwnership(Gfx::QueueType newOwner);
|
||||
void changeLayout(Gfx::SeImageLayout newLayout, VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
||||
VkPipelineStageFlags dstStage);
|
||||
@@ -37,11 +35,15 @@ class TextureHandle : public CommandBoundResource {
|
||||
VkImageAspectFlags aspect;
|
||||
uint8 ownsImage;
|
||||
};
|
||||
DECLARE_REF(TextureHandle)
|
||||
DEFINE_REF(TextureHandle)
|
||||
|
||||
DECLARE_REF(TextureBase)
|
||||
DECLARE_REF(Texture2D)
|
||||
DECLARE_REF(Texture3D)
|
||||
DECLARE_REF(TextureCube)
|
||||
class TextureBase {
|
||||
public:
|
||||
TextureBase(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo,
|
||||
VkImage existingImage = VK_NULL_HANDLE);
|
||||
TextureBase(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage = VK_NULL_HANDLE);
|
||||
virtual ~TextureBase();
|
||||
uint32 getWidth() const { return handle->width; }
|
||||
uint32 getHeight() const { return handle->height; }
|
||||
@@ -58,13 +60,13 @@ class TextureBase {
|
||||
constexpr uint32 getMipLevels() const { return handle->mipLevels; }
|
||||
constexpr bool isDepthStencil() const { return handle->aspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); }
|
||||
|
||||
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
||||
VkPipelineStageFlags dstStage);
|
||||
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
|
||||
void transferOwnership(Gfx::QueueType newOwner);
|
||||
void changeLayout(Gfx::SeImageLayout newLayout, VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
||||
VkPipelineStageFlags dstStage);
|
||||
void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer);
|
||||
void generateMipmaps();
|
||||
|
||||
protected:
|
||||
OTextureHandle handle;
|
||||
// Updates via reference
|
||||
|
||||
Reference in New Issue
Block a user