Commit 63ae9242 by Alexis Hetu Committed by Alexis Hétu

CommandBuffer and NonDispatchable objects code cleanup

Cleaned up items include: - Sanitized parameter names in Command constructors - Commands no longer hold Vk types for members if they can be cast to an internal type in the constructor - Commands members are private - VertexInputBinding contains a Buffer instead of a VkBuffer - Removed the Fence default constructor - Image functions now receive Image and Buffer objects instead of VkImage and VkBuffer handles. - Removed the VkNonDispatchableHandle default constructor - DeviceMemory::getOffsetPointer() is now const - Refactored PresentImage so that it no longer contains VkImage and VkDeviceMemory handles, but proper Image and DeviceMemory objects instead and replaced duplicate code which releases these objects with a clear() function. - SwapchainKHR no longer holds on to a VkSwapchainCreateInfoKHR structure, which was dangerous, since it contains pointers which were not deep copied, but only holds on to a SurfaceKHR object, which is the only thing it really needs. - SwapchainKHR::images never changes size, so it was changed from a vector to an array so that we can better control its memory allocation. - SurfaceKHR had a VkSwapchainKHR member, changed it for a SwapchainKHR* instead - Removed surfaceFormats and presentModes, which were unnecessarily bloating the SurfaceKHR class and moved them to an unnamed namespace in VkSurfaceKHR.cpp. Change-Id: If21e5ba1319759a204e562aef92aaf96d5a12b1f Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/32489 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarSean Risser <srisser@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 8de101cc
...@@ -33,6 +33,7 @@ namespace sw ...@@ -33,6 +33,7 @@ namespace sw
namespace vk namespace vk
{ {
class Buffer;
class Framebuffer; class Framebuffer;
class Pipeline; class Pipeline;
class RenderPass; class RenderPass;
...@@ -160,7 +161,7 @@ public: ...@@ -160,7 +161,7 @@ public:
struct VertexInputBinding struct VertexInputBinding
{ {
VkBuffer buffer; Buffer* buffer;
VkDeviceSize offset; VkDeviceSize offset;
}; };
VertexInputBinding vertexInputBindings[MAX_VERTEX_INPUT_BINDINGS] = {}; VertexInputBinding vertexInputBindings[MAX_VERTEX_INPUT_BINDINGS] = {};
......
...@@ -63,7 +63,7 @@ VkDeviceSize DeviceMemory::getCommittedMemoryInBytes() const ...@@ -63,7 +63,7 @@ VkDeviceSize DeviceMemory::getCommittedMemoryInBytes() const
return size; return size;
} }
void* DeviceMemory::getOffsetPointer(VkDeviceSize pOffset) void* DeviceMemory::getOffsetPointer(VkDeviceSize pOffset) const
{ {
ASSERT(buffer); ASSERT(buffer);
......
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
VkResult allocate(); VkResult allocate();
VkResult map(VkDeviceSize offset, VkDeviceSize size, void** ppData); VkResult map(VkDeviceSize offset, VkDeviceSize size, void** ppData);
VkDeviceSize getCommittedMemoryInBytes() const; VkDeviceSize getCommittedMemoryInBytes() const;
void* getOffsetPointer(VkDeviceSize pOffset); void* getOffsetPointer(VkDeviceSize pOffset) const;
uint32_t getMemoryTypeIndex() const { return memoryTypeIndex; } uint32_t getMemoryTypeIndex() const { return memoryTypeIndex; }
private: private:
......
...@@ -24,8 +24,6 @@ namespace vk ...@@ -24,8 +24,6 @@ namespace vk
class Fence : public Object<Fence, VkFence>, public sw::TaskEvents class Fence : public Object<Fence, VkFence>, public sw::TaskEvents
{ {
public: public:
Fence() : signaled(sw::Event::ClearMode::Manual, false) {}
Fence(const VkFenceCreateInfo* pCreateInfo, void* mem) : Fence(const VkFenceCreateInfo* pCreateInfo, void* mem) :
signaled(sw::Event::ClearMode::Manual, (pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT) != 0) {} signaled(sw::Event::ClearMode::Manual, (pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT) != 0) {}
......
...@@ -128,11 +128,10 @@ void Image::getSubresourceLayout(const VkImageSubresource* pSubresource, VkSubre ...@@ -128,11 +128,10 @@ void Image::getSubresourceLayout(const VkImageSubresource* pSubresource, VkSubre
pLayout->arrayPitch = getLayerSize(aspect); pLayout->arrayPitch = getLayerSize(aspect);
} }
void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion) void Image::copyTo(Image* dstImage, const VkImageCopy& pRegion) const
{ {
// Image copy does not perform any conversion, it simply copies memory from // Image copy does not perform any conversion, it simply copies memory from
// an image to another image that has the same number of bytes per pixel. // an image to another image that has the same number of bytes per pixel.
Image* dst = Cast(dstImage);
if (!((pRegion.srcSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) || if (!((pRegion.srcSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) ||
(pRegion.srcSubresource.aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT) || (pRegion.srcSubresource.aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT) ||
...@@ -158,7 +157,7 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion) ...@@ -158,7 +157,7 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion)
VkImageAspectFlagBits dstAspect = static_cast<VkImageAspectFlagBits>(pRegion.dstSubresource.aspectMask); VkImageAspectFlagBits dstAspect = static_cast<VkImageAspectFlagBits>(pRegion.dstSubresource.aspectMask);
Format srcFormat = getFormat(srcAspect); Format srcFormat = getFormat(srcAspect);
Format dstFormat = dst->getFormat(dstAspect); Format dstFormat = dstImage->getFormat(dstAspect);
if(((samples > VK_SAMPLE_COUNT_1_BIT) && (imageType == VK_IMAGE_TYPE_2D) && !format.isNonNormalizedInteger()) || if(((samples > VK_SAMPLE_COUNT_1_BIT) && (imageType == VK_IMAGE_TYPE_2D) && !format.isNonNormalizedInteger()) ||
srcFormat.hasQuadLayout() || dstFormat.hasQuadLayout()) srcFormat.hasQuadLayout() || dstFormat.hasQuadLayout())
...@@ -177,22 +176,22 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion) ...@@ -177,22 +176,22 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion)
region.dstOffsets[1].y = region.dstOffsets[0].y + pRegion.extent.height; region.dstOffsets[1].y = region.dstOffsets[0].y + pRegion.extent.height;
region.dstOffsets[1].z = region.dstOffsets[0].z + pRegion.extent.depth; region.dstOffsets[1].z = region.dstOffsets[0].z + pRegion.extent.depth;
return device->getBlitter()->blit(this, dst, region, VK_FILTER_NEAREST); return device->getBlitter()->blit(this, dstImage, region, VK_FILTER_NEAREST);
} }
int srcBytesPerBlock = srcFormat.bytesPerBlock(); int srcBytesPerBlock = srcFormat.bytesPerBlock();
ASSERT(srcBytesPerBlock == dstFormat.bytesPerBlock()); ASSERT(srcBytesPerBlock == dstFormat.bytesPerBlock());
const uint8_t* srcMem = static_cast<const uint8_t*>(getTexelPointer(pRegion.srcOffset, pRegion.srcSubresource)); const uint8_t* srcMem = static_cast<const uint8_t*>(getTexelPointer(pRegion.srcOffset, pRegion.srcSubresource));
uint8_t* dstMem = static_cast<uint8_t*>(dst->getTexelPointer(pRegion.dstOffset, pRegion.dstSubresource)); uint8_t* dstMem = static_cast<uint8_t*>(dstImage->getTexelPointer(pRegion.dstOffset, pRegion.dstSubresource));
int srcRowPitchBytes = rowPitchBytes(srcAspect, pRegion.srcSubresource.mipLevel); int srcRowPitchBytes = rowPitchBytes(srcAspect, pRegion.srcSubresource.mipLevel);
int srcSlicePitchBytes = slicePitchBytes(srcAspect, pRegion.srcSubresource.mipLevel); int srcSlicePitchBytes = slicePitchBytes(srcAspect, pRegion.srcSubresource.mipLevel);
int dstRowPitchBytes = dst->rowPitchBytes(dstAspect, pRegion.dstSubresource.mipLevel); int dstRowPitchBytes = dstImage->rowPitchBytes(dstAspect, pRegion.dstSubresource.mipLevel);
int dstSlicePitchBytes = dst->slicePitchBytes(dstAspect, pRegion.dstSubresource.mipLevel); int dstSlicePitchBytes = dstImage->slicePitchBytes(dstAspect, pRegion.dstSubresource.mipLevel);
VkExtent3D srcExtent = getMipLevelExtent(srcAspect, pRegion.srcSubresource.mipLevel); VkExtent3D srcExtent = getMipLevelExtent(srcAspect, pRegion.srcSubresource.mipLevel);
VkExtent3D dstExtent = dst->getMipLevelExtent(dstAspect, pRegion.dstSubresource.mipLevel); VkExtent3D dstExtent = dstImage->getMipLevelExtent(dstAspect, pRegion.dstSubresource.mipLevel);
VkExtent3D copyExtent = imageExtentInBlocks(pRegion.extent, srcAspect); VkExtent3D copyExtent = imageExtentInBlocks(pRegion.extent, srcAspect);
bool isSinglePlane = (copyExtent.depth == 1); bool isSinglePlane = (copyExtent.depth == 1);
...@@ -223,21 +222,21 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion) ...@@ -223,21 +222,21 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion)
{ {
size_t copySize = copyExtent.width * srcBytesPerBlock; size_t copySize = copyExtent.width * srcBytesPerBlock;
ASSERT((srcMem + copySize) < end()); ASSERT((srcMem + copySize) < end());
ASSERT((dstMem + copySize) < dst->end()); ASSERT((dstMem + copySize) < dstImage->end());
memcpy(dstMem, srcMem, copySize); memcpy(dstMem, srcMem, copySize);
} }
else if(isEntireLine && isSinglePlane) // Copy one plane else if(isEntireLine && isSinglePlane) // Copy one plane
{ {
size_t copySize = copyExtent.height * srcRowPitchBytes; size_t copySize = copyExtent.height * srcRowPitchBytes;
ASSERT((srcMem + copySize) < end()); ASSERT((srcMem + copySize) < end());
ASSERT((dstMem + copySize) < dst->end()); ASSERT((dstMem + copySize) < dstImage->end());
memcpy(dstMem, srcMem, copySize); memcpy(dstMem, srcMem, copySize);
} }
else if(isEntirePlane) // Copy multiple planes else if(isEntirePlane) // Copy multiple planes
{ {
size_t copySize = copyExtent.depth * srcSlicePitchBytes; size_t copySize = copyExtent.depth * srcSlicePitchBytes;
ASSERT((srcMem + copySize) < end()); ASSERT((srcMem + copySize) < end());
ASSERT((dstMem + copySize) < dst->end()); ASSERT((dstMem + copySize) < dstImage->end());
memcpy(dstMem, srcMem, copySize); memcpy(dstMem, srcMem, copySize);
} }
else if(isEntireLine) // Copy plane by plane else if(isEntireLine) // Copy plane by plane
...@@ -247,7 +246,7 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion) ...@@ -247,7 +246,7 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion)
for(uint32_t z = 0; z < copyExtent.depth; z++, dstMem += dstSlicePitchBytes, srcMem += srcSlicePitchBytes) for(uint32_t z = 0; z < copyExtent.depth; z++, dstMem += dstSlicePitchBytes, srcMem += srcSlicePitchBytes)
{ {
ASSERT((srcMem + copySize) < end()); ASSERT((srcMem + copySize) < end());
ASSERT((dstMem + copySize) < dst->end()); ASSERT((dstMem + copySize) < dstImage->end());
memcpy(dstMem, srcMem, copySize); memcpy(dstMem, srcMem, copySize);
} }
} }
...@@ -260,14 +259,14 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion) ...@@ -260,14 +259,14 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion)
for(uint32_t y = 0; y < copyExtent.height; y++, dstMem += dstRowPitchBytes, srcMem += srcRowPitchBytes) for(uint32_t y = 0; y < copyExtent.height; y++, dstMem += dstRowPitchBytes, srcMem += srcRowPitchBytes)
{ {
ASSERT((srcMem + copySize) < end()); ASSERT((srcMem + copySize) < end());
ASSERT((dstMem + copySize) < dst->end()); ASSERT((dstMem + copySize) < dstImage->end());
memcpy(dstMem, srcMem, copySize); memcpy(dstMem, srcMem, copySize);
} }
} }
} }
} }
void Image::copy(VkBuffer buf, const VkBufferImageCopy& region, bool bufferIsSource) void Image::copy(Buffer* buffer, const VkBufferImageCopy& region, bool bufferIsSource)
{ {
switch(region.imageSubresource.aspectMask) switch(region.imageSubresource.aspectMask)
{ {
...@@ -292,7 +291,6 @@ void Image::copy(VkBuffer buf, const VkBufferImageCopy& region, bool bufferIsSou ...@@ -292,7 +291,6 @@ void Image::copy(VkBuffer buf, const VkBufferImageCopy& region, bool bufferIsSou
int bufferRowPitchBytes = bufferExtent.width * bytesPerBlock; int bufferRowPitchBytes = bufferExtent.width * bytesPerBlock;
int bufferSlicePitchBytes = bufferExtent.height * bufferRowPitchBytes; int bufferSlicePitchBytes = bufferExtent.height * bufferRowPitchBytes;
Buffer* buffer = Cast(buf);
uint8_t* bufferMemory = static_cast<uint8_t*>(buffer->getOffsetPointer(region.bufferOffset)); uint8_t* bufferMemory = static_cast<uint8_t*>(buffer->getOffsetPointer(region.bufferOffset));
if (copyFormat.hasQuadLayout()) if (copyFormat.hasQuadLayout())
...@@ -415,12 +413,12 @@ void Image::copy(VkBuffer buf, const VkBufferImageCopy& region, bool bufferIsSou ...@@ -415,12 +413,12 @@ void Image::copy(VkBuffer buf, const VkBufferImageCopy& region, bool bufferIsSou
} }
} }
void Image::copyTo(VkBuffer dstBuffer, const VkBufferImageCopy& region) void Image::copyTo(Buffer* dstBuffer, const VkBufferImageCopy& region)
{ {
copy(dstBuffer, region, false); copy(dstBuffer, region, false);
} }
void Image::copyFrom(VkBuffer srcBuffer, const VkBufferImageCopy& region) void Image::copyFrom(Buffer* srcBuffer, const VkBufferImageCopy& region)
{ {
copy(srcBuffer, region, true); copy(srcBuffer, region, true);
} }
...@@ -730,12 +728,12 @@ const Image* Image::getSampledImage(const vk::Format& imageViewFormat) const ...@@ -730,12 +728,12 @@ const Image* Image::getSampledImage(const vk::Format& imageViewFormat) const
return (decompressedImage && isImageViewCompressed) ? decompressedImage : this; return (decompressedImage && isImageViewCompressed) ? decompressedImage : this;
} }
void Image::blit(VkImage dstImage, const VkImageBlit& region, VkFilter filter) void Image::blit(Image* dstImage, const VkImageBlit& region, VkFilter filter) const
{ {
device->getBlitter()->blit(this, Cast(dstImage), region, filter); device->getBlitter()->blit(this, dstImage, region, filter);
} }
void Image::resolve(VkImage dstImage, const VkImageResolve& region) void Image::resolve(Image* dstImage, const VkImageResolve& region) const
{ {
VkImageBlit blitRegion; VkImageBlit blitRegion;
...@@ -752,7 +750,7 @@ void Image::resolve(VkImage dstImage, const VkImageResolve& region) ...@@ -752,7 +750,7 @@ void Image::resolve(VkImage dstImage, const VkImageResolve& region)
blitRegion.srcSubresource = region.srcSubresource; blitRegion.srcSubresource = region.srcSubresource;
blitRegion.dstSubresource = region.dstSubresource; blitRegion.dstSubresource = region.dstSubresource;
device->getBlitter()->blit(this, Cast(dstImage), blitRegion, VK_FILTER_NEAREST); device->getBlitter()->blit(this, dstImage, blitRegion, VK_FILTER_NEAREST);
} }
VkFormat Image::getClearFormat() const VkFormat Image::getClearFormat() const
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
namespace vk namespace vk
{ {
class Buffer;
class Device; class Device;
class DeviceMemory; class DeviceMemory;
...@@ -35,12 +36,12 @@ public: ...@@ -35,12 +36,12 @@ public:
const VkMemoryRequirements getMemoryRequirements() const; const VkMemoryRequirements getMemoryRequirements() const;
void getSubresourceLayout(const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) const; void getSubresourceLayout(const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) const;
void bind(VkDeviceMemory pDeviceMemory, VkDeviceSize pMemoryOffset); void bind(VkDeviceMemory pDeviceMemory, VkDeviceSize pMemoryOffset);
void copyTo(VkImage dstImage, const VkImageCopy& pRegion); void copyTo(Image* dstImage, const VkImageCopy& pRegion) const;
void copyTo(VkBuffer dstBuffer, const VkBufferImageCopy& region); void copyTo(Buffer* dstBuffer, const VkBufferImageCopy& region);
void copyFrom(VkBuffer srcBuffer, const VkBufferImageCopy& region); void copyFrom(Buffer* srcBuffer, const VkBufferImageCopy& region);
void blit(VkImage dstImage, const VkImageBlit& region, VkFilter filter); void blit(Image* dstImage, const VkImageBlit& region, VkFilter filter) const;
void resolve(VkImage dstImage, const VkImageResolve& region); void resolve(Image* dstImage, const VkImageResolve& region) const;
void clear(const VkClearValue& clearValue, const vk::Format& viewFormat, const VkRect2D& renderArea, const VkImageSubresourceRange& subresourceRange); void clear(const VkClearValue& clearValue, const vk::Format& viewFormat, const VkRect2D& renderArea, const VkImageSubresourceRange& subresourceRange);
void clear(const VkClearColorValue& color, const VkImageSubresourceRange& subresourceRange); void clear(const VkClearColorValue& color, const VkImageSubresourceRange& subresourceRange);
void clear(const VkClearDepthStencilValue& color, const VkImageSubresourceRange& subresourceRange); void clear(const VkClearDepthStencilValue& color, const VkImageSubresourceRange& subresourceRange);
...@@ -67,7 +68,7 @@ public: ...@@ -67,7 +68,7 @@ public:
const Image* getSampledImage(const vk::Format& imageViewFormat) const; const Image* getSampledImage(const vk::Format& imageViewFormat) const;
private: private:
void copy(VkBuffer buffer, const VkBufferImageCopy& region, bool bufferIsSource); void copy(Buffer* buffer, const VkBufferImageCopy& region, bool bufferIsSource);
VkDeviceSize getStorageSize(VkImageAspectFlags flags) const; VkDeviceSize getStorageSize(VkImageAspectFlags flags) const;
VkDeviceSize getMipLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel) const; VkDeviceSize getMipLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
VkDeviceSize getMultiSampledLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel) const; VkDeviceSize getMultiSampledLevelSize(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
......
...@@ -181,7 +181,7 @@ void ImageView::resolve(ImageView* resolveAttachment) ...@@ -181,7 +181,7 @@ void ImageView::resolve(ImageView* resolveAttachment)
region.extent = image->getMipLevelExtent(static_cast<VkImageAspectFlagBits>(subresourceRange.aspectMask), region.extent = image->getMipLevelExtent(static_cast<VkImageAspectFlagBits>(subresourceRange.aspectMask),
subresourceRange.baseMipLevel); subresourceRange.baseMipLevel);
image->copyTo(*(resolveAttachment->image), region); image->copyTo(resolveAttachment->image, region);
} }
const Image* ImageView::getImage(Usage usage) const const Image* ImageView::getImage(Usage usage) const
......
...@@ -98,10 +98,6 @@ public: ...@@ -98,10 +98,6 @@ public:
template<typename T> class VkNonDispatchableHandle : public VkNonDispatchableHandleBase<T> template<typename T> class VkNonDispatchableHandle : public VkNonDispatchableHandleBase<T>
{ {
public: public:
VkNonDispatchableHandle() : VkNonDispatchableHandleBase<T>(nullptr)
{
}
VkNonDispatchableHandle(typename VkNonDispatchableHandleBase<T>::HandleType handle) : VkNonDispatchableHandleBase<T>(handle) VkNonDispatchableHandle(typename VkNonDispatchableHandleBase<T>::HandleType handle) : VkNonDispatchableHandleBase<T>(handle)
{ {
static_assert(sizeof(VkNonDispatchableHandle) == sizeof(uint64_t), "Size is not 64 bits!"); static_assert(sizeof(VkNonDispatchableHandle) == sizeof(uint64_t), "Size is not 64 bits!");
......
...@@ -2652,7 +2652,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwa ...@@ -2652,7 +2652,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwa
vk::Cast(pCreateInfo->oldSwapchain)->retire(); vk::Cast(pCreateInfo->oldSwapchain)->retire();
} }
if(vk::Cast(pCreateInfo->surface)->getAssociatedSwapchain() != VK_NULL_HANDLE) if(vk::Cast(pCreateInfo->surface)->hasAssociatedSwapchain())
{ {
return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR; return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
} }
...@@ -2664,7 +2664,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwa ...@@ -2664,7 +2664,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwa
return status; return status;
} }
status = vk::Cast(*pSwapchain)->createImages(device); status = vk::Cast(*pSwapchain)->createImages(device, pCreateInfo);
if(status != VK_SUCCESS) if(status != VK_SUCCESS)
{ {
......
...@@ -14,11 +14,98 @@ ...@@ -14,11 +14,98 @@
#include "VkSurfaceKHR.hpp" #include "VkSurfaceKHR.hpp"
#include "Vulkan/VkDestroy.h"
#include <algorithm> #include <algorithm>
namespace
{
static const VkSurfaceFormatKHR surfaceFormats[] =
{
{VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR},
};
static const VkPresentModeKHR presentModes[] =
{
VK_PRESENT_MODE_FIFO_KHR,
};
}
namespace vk namespace vk
{ {
VkResult PresentImage::allocateImage(VkDevice device, const VkImageCreateInfo& createInfo)
{
VkImage* vkImagePtr = reinterpret_cast<VkImage*>(allocate(sizeof(VkImage), REQUIRED_MEMORY_ALIGNMENT, DEVICE_MEMORY));
if(!vkImagePtr)
{
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
}
VkResult status = vkCreateImage(device, &createInfo, nullptr, vkImagePtr);
if(status != VK_SUCCESS)
{
deallocate(vkImagePtr, DEVICE_MEMORY);
return status;
}
image = Cast(*vkImagePtr);
deallocate(vkImagePtr, DEVICE_MEMORY);
return status;
}
VkResult PresentImage::allocateAndBindImageMemory(VkDevice device, const VkMemoryAllocateInfo& allocateInfo)
{
ASSERT(image);
VkDeviceMemory* vkDeviceMemoryPtr = reinterpret_cast<VkDeviceMemory*>(
allocate(sizeof(VkDeviceMemory), REQUIRED_MEMORY_ALIGNMENT, DEVICE_MEMORY));
if(!vkDeviceMemoryPtr)
{
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
}
VkResult status = vkAllocateMemory(device, &allocateInfo, nullptr, vkDeviceMemoryPtr);
if(status != VK_SUCCESS)
{
deallocate(vkDeviceMemoryPtr, DEVICE_MEMORY);
return status;
}
imageMemory = Cast(*vkDeviceMemoryPtr);
vkBindImageMemory(device, *image, *vkDeviceMemoryPtr, 0);
imageStatus = AVAILABLE;
deallocate(vkDeviceMemoryPtr, DEVICE_MEMORY);
return status;
}
void PresentImage::clear()
{
if(imageMemory)
{
vk::destroy(static_cast<VkDeviceMemory>(*imageMemory), nullptr);
imageMemory = nullptr;
}
if(image)
{
vk::destroy(static_cast<VkImage>(*image), nullptr);
image = nullptr;
}
imageStatus = NONEXISTENT;
}
VkImage PresentImage::asVkImage() const
{
return image ? static_cast<VkImage>(*image) : VK_NULL_HANDLE;
}
void SurfaceKHR::getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) const void SurfaceKHR::getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) const
{ {
pSurfaceCapabilities->minImageCount = 1; pSurfaceCapabilities->minImageCount = 1;
...@@ -34,7 +121,7 @@ void SurfaceKHR::getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabi ...@@ -34,7 +121,7 @@ void SurfaceKHR::getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabi
uint32_t SurfaceKHR::getSurfaceFormatsCount() const uint32_t SurfaceKHR::getSurfaceFormatsCount() const
{ {
return static_cast<uint32_t>(surfaceFormats.size()); return static_cast<uint32_t>(sizeof(surfaceFormats) / sizeof(surfaceFormats[0]));
} }
VkResult SurfaceKHR::getSurfaceFormats(uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) const VkResult SurfaceKHR::getSurfaceFormats(uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) const
...@@ -49,7 +136,7 @@ VkResult SurfaceKHR::getSurfaceFormats(uint32_t *pSurfaceFormatCount, VkSurfaceF ...@@ -49,7 +136,7 @@ VkResult SurfaceKHR::getSurfaceFormats(uint32_t *pSurfaceFormatCount, VkSurfaceF
*pSurfaceFormatCount = i; *pSurfaceFormatCount = i;
if (*pSurfaceFormatCount < count) if(*pSurfaceFormatCount < count)
{ {
return VK_INCOMPLETE; return VK_INCOMPLETE;
} }
...@@ -59,10 +146,9 @@ VkResult SurfaceKHR::getSurfaceFormats(uint32_t *pSurfaceFormatCount, VkSurfaceF ...@@ -59,10 +146,9 @@ VkResult SurfaceKHR::getSurfaceFormats(uint32_t *pSurfaceFormatCount, VkSurfaceF
uint32_t SurfaceKHR::getPresentModeCount() const uint32_t SurfaceKHR::getPresentModeCount() const
{ {
return static_cast<uint32_t>(presentModes.size()); return static_cast<uint32_t>(sizeof(presentModes) / sizeof(presentModes[0]));
} }
VkResult SurfaceKHR::getPresentModes(uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) const VkResult SurfaceKHR::getPresentModes(uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) const
{ {
uint32_t count = getPresentModeCount(); uint32_t count = getPresentModeCount();
...@@ -75,7 +161,7 @@ VkResult SurfaceKHR::getPresentModes(uint32_t *pPresentModeCount, VkPresentModeK ...@@ -75,7 +161,7 @@ VkResult SurfaceKHR::getPresentModes(uint32_t *pPresentModeCount, VkPresentModeK
*pPresentModeCount = i; *pPresentModeCount = i;
if (*pPresentModeCount < count) if(*pPresentModeCount < count)
{ {
return VK_INCOMPLETE; return VK_INCOMPLETE;
} }
...@@ -85,17 +171,17 @@ VkResult SurfaceKHR::getPresentModes(uint32_t *pPresentModeCount, VkPresentModeK ...@@ -85,17 +171,17 @@ VkResult SurfaceKHR::getPresentModes(uint32_t *pPresentModeCount, VkPresentModeK
void SurfaceKHR::associateSwapchain(VkSwapchainKHR swapchain) void SurfaceKHR::associateSwapchain(VkSwapchainKHR swapchain)
{ {
associatedSwapchain = swapchain; associatedSwapchain = Cast(swapchain);
} }
void SurfaceKHR::disassociateSwapchain() void SurfaceKHR::disassociateSwapchain()
{ {
associatedSwapchain = VK_NULL_HANDLE; associatedSwapchain = nullptr;
} }
VkSwapchainKHR SurfaceKHR::getAssociatedSwapchain() bool SurfaceKHR::hasAssociatedSwapchain()
{ {
return associatedSwapchain; return (associatedSwapchain != nullptr);
} }
} }
\ No newline at end of file
...@@ -30,11 +30,28 @@ enum PresentImageStatus ...@@ -30,11 +30,28 @@ enum PresentImageStatus
PRESENTING, PRESENTING,
}; };
struct PresentImage class DeviceMemory;
class Image;
class SwapchainKHR;
class PresentImage
{ {
VkImage image; public:
VkDeviceMemory imageMemory; VkResult allocateImage(VkDevice device, const VkImageCreateInfo& createInfo);
PresentImageStatus imageStatus; VkResult allocateAndBindImageMemory(VkDevice device, const VkMemoryAllocateInfo& allocateInfo);
void clear();
VkImage asVkImage() const;
const Image* getImage() const { return image; }
const DeviceMemory* getImageMemory() const { return imageMemory; }
bool isAvailable() const { return (imageStatus == AVAILABLE); }
bool exists() const { return (imageStatus != NONEXISTENT); }
void setStatus(PresentImageStatus status) { imageStatus = status; }
private:
Image* image = nullptr;
DeviceMemory* imageMemory = nullptr;
PresentImageStatus imageStatus = NONEXISTENT;
}; };
class SurfaceKHR class SurfaceKHR
...@@ -68,21 +85,10 @@ public: ...@@ -68,21 +85,10 @@ public:
void associateSwapchain(VkSwapchainKHR swapchain); void associateSwapchain(VkSwapchainKHR swapchain);
void disassociateSwapchain(); void disassociateSwapchain();
VkSwapchainKHR getAssociatedSwapchain(); bool hasAssociatedSwapchain();
private: private:
VkSwapchainKHR associatedSwapchain; SwapchainKHR* associatedSwapchain = nullptr;
const std::vector<VkSurfaceFormatKHR> surfaceFormats =
{
{VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR},
};
const std::vector<VkPresentModeKHR> presentModes =
{
VK_PRESENT_MODE_FIFO_KHR,
};
}; };
static inline SurfaceKHR* Cast(VkSurfaceKHR object) static inline SurfaceKHR* Cast(VkSurfaceKHR object)
......
...@@ -14,46 +14,49 @@ ...@@ -14,46 +14,49 @@
#include "VkSwapchainKHR.hpp" #include "VkSwapchainKHR.hpp"
#include "Vulkan/VkImage.hpp"
#include "Vulkan/VkDeviceMemory.hpp" #include "Vulkan/VkDeviceMemory.hpp"
#include "Vulkan/VkDestroy.h" #include "Vulkan/VkFence.hpp"
#include "Vulkan/VkImage.hpp"
#include "Vulkan/VkSemaphore.hpp"
#include <algorithm> #include <algorithm>
#include <cstring>
namespace vk namespace vk
{ {
SwapchainKHR::SwapchainKHR(const VkSwapchainCreateInfoKHR *pCreateInfo, void *mem) : SwapchainKHR::SwapchainKHR(const VkSwapchainCreateInfoKHR *pCreateInfo, void *mem) :
createInfo(*pCreateInfo), surface(Cast(pCreateInfo->surface)),
images(reinterpret_cast<PresentImage*>(mem)),
imageCount(pCreateInfo->minImageCount),
retired(false) retired(false)
{ {
images.resize(pCreateInfo->minImageCount); memset(images, 0, imageCount * sizeof(PresentImage));
resetImages();
} }
void SwapchainKHR::destroy(const VkAllocationCallbacks *pAllocator) void SwapchainKHR::destroy(const VkAllocationCallbacks *pAllocator)
{ {
for(auto& currentImage : images) for(uint32_t i = 0; i < imageCount; i++)
{ {
if (currentImage.imageStatus != NONEXISTENT) PresentImage& currentImage = images[i];
if(currentImage.exists())
{ {
vk::Cast(createInfo.surface)->detachImage(&currentImage); surface->detachImage(&currentImage);
vk::destroy(currentImage.imageMemory, nullptr); currentImage.clear();
vk::destroy(currentImage.image, nullptr);
currentImage.imageStatus = NONEXISTENT;
} }
} }
if(!retired) if(!retired)
{ {
vk::Cast(createInfo.surface)->disassociateSwapchain(); surface->disassociateSwapchain();
} }
vk::deallocate(images, pAllocator);
} }
size_t SwapchainKHR::ComputeRequiredAllocationSize(const VkSwapchainCreateInfoKHR *pCreateInfo) size_t SwapchainKHR::ComputeRequiredAllocationSize(const VkSwapchainCreateInfoKHR *pCreateInfo)
{ {
return 0; return pCreateInfo->minImageCount * sizeof(PresentImage);
} }
void SwapchainKHR::retire() void SwapchainKHR::retire()
...@@ -61,17 +64,15 @@ void SwapchainKHR::retire() ...@@ -61,17 +64,15 @@ void SwapchainKHR::retire()
if(!retired) if(!retired)
{ {
retired = true; retired = true;
vk::Cast(createInfo.surface)->disassociateSwapchain(); surface->disassociateSwapchain();
for(auto& currentImage : images) for(uint32_t i = 0; i < imageCount; i++)
{ {
if(currentImage.imageStatus == AVAILABLE) PresentImage& currentImage = images[i];
if(currentImage.isAvailable())
{ {
vk::Cast(createInfo.surface)->detachImage(&currentImage); surface->detachImage(&currentImage);
vk::destroy(currentImage.imageMemory, nullptr); currentImage.clear();
vk::destroy(currentImage.image, nullptr);
currentImage.imageStatus = NONEXISTENT;
} }
} }
} }
...@@ -79,73 +80,69 @@ void SwapchainKHR::retire() ...@@ -79,73 +80,69 @@ void SwapchainKHR::retire()
void SwapchainKHR::resetImages() void SwapchainKHR::resetImages()
{ {
for(auto& currentImage : images) for(uint32_t i = 0; i < imageCount; i++)
{ {
currentImage.image = VK_NULL_HANDLE; images[i].clear();
currentImage.imageMemory = VK_NULL_HANDLE;
currentImage.imageStatus = NONEXISTENT;
} }
} }
VkResult SwapchainKHR::createImages(VkDevice device) VkResult SwapchainKHR::createImages(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo)
{ {
resetImages(); resetImages();
VkImageCreateInfo imageInfo = {}; VkImageCreateInfo imageInfo = {};
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
if(createInfo.flags & VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR) if(pCreateInfo->flags & VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR)
{ {
imageInfo.flags |= VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT; imageInfo.flags |= VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT;
} }
if(createInfo.flags & VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR) if(pCreateInfo->flags & VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR)
{ {
imageInfo.flags |= VK_IMAGE_CREATE_PROTECTED_BIT; imageInfo.flags |= VK_IMAGE_CREATE_PROTECTED_BIT;
} }
imageInfo.imageType = VK_IMAGE_TYPE_2D; imageInfo.imageType = VK_IMAGE_TYPE_2D;
imageInfo.format = createInfo.imageFormat; imageInfo.format = pCreateInfo->imageFormat;
imageInfo.extent.height = createInfo.imageExtent.height; imageInfo.extent.height = pCreateInfo->imageExtent.height;
imageInfo.extent.width = createInfo.imageExtent.width; imageInfo.extent.width = pCreateInfo->imageExtent.width;
imageInfo.extent.depth = 1; imageInfo.extent.depth = 1;
imageInfo.mipLevels = 1; imageInfo.mipLevels = 1;
imageInfo.arrayLayers = createInfo.imageArrayLayers; imageInfo.arrayLayers = pCreateInfo->imageArrayLayers;
imageInfo.samples = VK_SAMPLE_COUNT_1_BIT; imageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL; imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
imageInfo.usage = createInfo.imageUsage; imageInfo.usage = pCreateInfo->imageUsage;
imageInfo.sharingMode = createInfo.imageSharingMode; imageInfo.sharingMode = pCreateInfo->imageSharingMode;
imageInfo.pQueueFamilyIndices = createInfo.pQueueFamilyIndices; imageInfo.pQueueFamilyIndices = pCreateInfo->pQueueFamilyIndices;
imageInfo.queueFamilyIndexCount = createInfo.queueFamilyIndexCount; imageInfo.queueFamilyIndexCount = pCreateInfo->queueFamilyIndexCount;
imageInfo.initialLayout = VK_IMAGE_LAYOUT_GENERAL; imageInfo.initialLayout = VK_IMAGE_LAYOUT_GENERAL;
VkMemoryAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.allocationSize = 0;
allocInfo.memoryTypeIndex = 0;
VkResult status; VkResult status;
for(auto& currentImage : images) for(uint32_t i = 0; i < imageCount; i++)
{ {
status = vkCreateImage(device, &imageInfo, nullptr, &currentImage.image); PresentImage& currentImage = images[i];
status = currentImage.allocateImage(device, imageInfo);
if(status != VK_SUCCESS) if(status != VK_SUCCESS)
{ {
return status; return status;
} }
VkMemoryRequirements memRequirements = vk::Cast(currentImage.image)->getMemoryRequirements(); allocInfo.allocationSize = currentImage.getImage()->getMemoryRequirements().size;
VkMemoryAllocateInfo allocInfo = {}; status = currentImage.allocateAndBindImageMemory(device, allocInfo);
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.allocationSize = memRequirements.size;
allocInfo.memoryTypeIndex = 0;
status = vkAllocateMemory(device, &allocInfo, nullptr, &currentImage.imageMemory);
if(status != VK_SUCCESS) if(status != VK_SUCCESS)
{ {
return status; return status;
} }
vkBindImageMemory(device, currentImage.image, currentImage.imageMemory, 0); surface->attachImage(&currentImage);
currentImage.imageStatus = AVAILABLE;
vk::Cast(createInfo.surface)->attachImage(&currentImage);
} }
return VK_SUCCESS; return VK_SUCCESS;
...@@ -153,22 +150,20 @@ VkResult SwapchainKHR::createImages(VkDevice device) ...@@ -153,22 +150,20 @@ VkResult SwapchainKHR::createImages(VkDevice device)
uint32_t SwapchainKHR::getImageCount() const uint32_t SwapchainKHR::getImageCount() const
{ {
return static_cast<uint32_t >(images.size()); return imageCount;
} }
VkResult SwapchainKHR::getImages(uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) const VkResult SwapchainKHR::getImages(uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) const
{ {
uint32_t count = getImageCount();
uint32_t i; uint32_t i;
for (i = 0; i < std::min(*pSwapchainImageCount, count); i++) for(i = 0; i < std::min(*pSwapchainImageCount, imageCount); i++)
{ {
pSwapchainImages[i] = images[i].image; pSwapchainImages[i] = images[i].asVkImage();
} }
*pSwapchainImageCount = i; *pSwapchainImageCount = i;
if (*pSwapchainImageCount < count) if(*pSwapchainImageCount < imageCount)
{ {
return VK_INCOMPLETE; return VK_INCOMPLETE;
} }
...@@ -178,12 +173,12 @@ VkResult SwapchainKHR::getImages(uint32_t *pSwapchainImageCount, VkImage *pSwapc ...@@ -178,12 +173,12 @@ VkResult SwapchainKHR::getImages(uint32_t *pSwapchainImageCount, VkImage *pSwapc
VkResult SwapchainKHR::getNextImage(uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) VkResult SwapchainKHR::getNextImage(uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex)
{ {
for(uint32_t i = 0; i < getImageCount(); i++) for(uint32_t i = 0; i < imageCount; i++)
{ {
PresentImage& currentImage = images[i]; PresentImage& currentImage = images[i];
if(currentImage.imageStatus == AVAILABLE) if(currentImage.isAvailable())
{ {
currentImage.imageStatus = DRAWING; currentImage.setStatus(DRAWING);
*pImageIndex = i; *pImageIndex = i;
if(semaphore) if(semaphore)
...@@ -206,17 +201,14 @@ VkResult SwapchainKHR::getNextImage(uint64_t timeout, VkSemaphore semaphore, VkF ...@@ -206,17 +201,14 @@ VkResult SwapchainKHR::getNextImage(uint64_t timeout, VkSemaphore semaphore, VkF
void SwapchainKHR::present(uint32_t index) void SwapchainKHR::present(uint32_t index)
{ {
auto & image = images[index]; auto & image = images[index];
image.imageStatus = PRESENTING; image.setStatus(PRESENTING);
vk::Cast(createInfo.surface)->present(&image); surface->present(&image);
image.imageStatus = AVAILABLE; image.setStatus(AVAILABLE);
if(retired) if(retired)
{ {
vk::Cast(createInfo.surface)->detachImage(&image); surface->detachImage(&image);
vk::destroy(image.imageMemory, nullptr); image.clear();
vk::destroy(image.image, nullptr);
image.imageStatus = NONEXISTENT;
} }
} }
......
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
void retire(); void retire();
VkResult createImages(VkDevice device); VkResult createImages(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo);
uint32_t getImageCount() const; uint32_t getImageCount() const;
VkResult getImages(uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) const; VkResult getImages(uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) const;
...@@ -46,9 +46,10 @@ public: ...@@ -46,9 +46,10 @@ public:
void present(uint32_t index); void present(uint32_t index);
private: private:
VkSwapchainCreateInfoKHR createInfo; SurfaceKHR* surface = nullptr;
std::vector<PresentImage> images; PresentImage* images = nullptr;
bool retired; uint32_t imageCount = 0;
bool retired = false;
void resetImages(); void resetImages();
}; };
......
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
#include "XlibSurfaceKHR.hpp" #include "XlibSurfaceKHR.hpp"
#include "Vulkan/VkDeviceMemory.hpp" #include "Vulkan/VkDeviceMemory.hpp"
#include "Vulkan/VkImage.hpp"
#include <string.h> #include <string.h>
namespace vk { namespace vk {
XlibSurfaceKHR::XlibSurfaceKHR(const VkXlibSurfaceCreateInfoKHR *pCreateInfo, void *mem) : XlibSurfaceKHR::XlibSurfaceKHR(const VkXlibSurfaceCreateInfoKHR *pCreateInfo, void *mem) :
pDisplay(pCreateInfo->dpy), pDisplay(pCreateInfo->dpy),
window(pCreateInfo->window) window(pCreateInfo->window)
{ {
int screen = DefaultScreen(pDisplay); int screen = DefaultScreen(pDisplay);
gc = libX11->XDefaultGC(pDisplay, screen); gc = libX11->XDefaultGC(pDisplay, screen);
...@@ -58,10 +59,10 @@ void XlibSurfaceKHR::attachImage(PresentImage* image) ...@@ -58,10 +59,10 @@ void XlibSurfaceKHR::attachImage(PresentImage* image)
XWindowAttributes attr; XWindowAttributes attr;
libX11->XGetWindowAttributes(pDisplay, window, &attr); libX11->XGetWindowAttributes(pDisplay, window, &attr);
VkExtent3D extent = vk::Cast(image->image)->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0); VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0);
int bytes_per_line = vk::Cast(image->image)->rowPitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0); int bytes_per_line = image->getImage()->rowPitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0);
char* buffer = static_cast<char*>(vk::Cast(image->imageMemory)->getOffsetPointer(0)); char* buffer = static_cast<char*>(image->getImageMemory()->getOffsetPointer(0));
XImage* xImage = libX11->XCreateImage(pDisplay, visual, attr.depth, ZPixmap, 0, buffer, extent.width, extent.height, 32, bytes_per_line); XImage* xImage = libX11->XCreateImage(pDisplay, visual, attr.depth, ZPixmap, 0, buffer, extent.width, extent.height, 32, bytes_per_line);
...@@ -89,7 +90,7 @@ void XlibSurfaceKHR::present(PresentImage* image) ...@@ -89,7 +90,7 @@ void XlibSurfaceKHR::present(PresentImage* image)
if(xImage->data) if(xImage->data)
{ {
VkExtent3D extent = vk::Cast(image->image)->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0); VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0);
libX11->XPutImage(pDisplay, window, gc, xImage, 0, 0, 0, 0, extent.width, extent.height); libX11->XPutImage(pDisplay, window, gc, xImage, 0, 0, 0, 0, extent.width, extent.height);
} }
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#define SWIFTSHADER_XLIBSURFACEKHR_HPP #define SWIFTSHADER_XLIBSURFACEKHR_HPP
#include "Vulkan/VkObject.hpp" #include "Vulkan/VkObject.hpp"
#include "Vulkan/VkImage.hpp"
#include "libX11.hpp" #include "libX11.hpp"
#include "VkSurfaceKHR.hpp" #include "VkSurfaceKHR.hpp"
#include "vulkan/vulkan_xlib.h" #include "vulkan/vulkan_xlib.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment