mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
vulkan: fix depth stencil textures
This commit is contained in:
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
|
||||||
@@ -107,15 +127,15 @@ ptrdiff_t Buffer::getTexelBufferHandle() const
|
|||||||
return (ptrdiff_t) bufferView;
|
return (ptrdiff_t) bufferView;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Buffer::map(MapType map, size_t offset, size_t size)
|
void *Buffer::map(MapType map, size_t offset, size_t size)
|
||||||
{
|
{
|
||||||
char* data = (char*)allocInfo.pMappedData;
|
char *data = (char*)allocInfo.pMappedData;
|
||||||
return (void*) (data + offset);
|
return (void*) (data + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Buffer::fill(size_t offset, size_t size, const void *data)
|
bool Buffer::fill(size_t offset, size_t size, const void *data)
|
||||||
{
|
{
|
||||||
void* dst = (void*)((char*)allocInfo.pMappedData + offset);
|
void *dst = (void*)((char*)allocInfo.pMappedData + offset);
|
||||||
memcpy(dst, data, size);
|
memcpy(dst, data, size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graphics/Buffer.h"
|
#include "graphics/Buffer.h"
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#include "common/Exception.h"
|
#include "common/Exception.h"
|
||||||
#include "common/pixelformat.h"
|
#include "common/pixelformat.h"
|
||||||
#include "common/version.h"
|
#include "common/version.h"
|
||||||
@@ -28,20 +48,14 @@ namespace graphics
|
|||||||
namespace vulkan
|
namespace vulkan
|
||||||
{
|
{
|
||||||
|
|
||||||
const std::vector<const char*> validationLayers = {
|
static const std::vector<const char*> validationLayers = {
|
||||||
"VK_LAYER_KHRONOS_validation"
|
"VK_LAYER_KHRONOS_validation"
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::vector<const char*> deviceExtensions = {
|
static const std::vector<const char*> deviceExtensions = {
|
||||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
constexpr bool enableValidationLayers = false;
|
|
||||||
#else
|
|
||||||
constexpr bool enableValidationLayers = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
constexpr int MAX_FRAMES_IN_FLIGHT = 2;
|
constexpr int MAX_FRAMES_IN_FLIGHT = 2;
|
||||||
|
|
||||||
const char *Graphics::getName() const
|
const char *Graphics::getName() const
|
||||||
@@ -67,6 +81,8 @@ Graphics::Graphics()
|
|||||||
volkInitializeCustom((PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr());
|
volkInitializeCustom((PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr());
|
||||||
|
|
||||||
vulkanApiVersion = volkGetInstanceVersion();
|
vulkanApiVersion = volkGetInstanceVersion();
|
||||||
|
|
||||||
|
enableValidationLayers = isDebugEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics::~Graphics()
|
Graphics::~Graphics()
|
||||||
@@ -526,8 +542,8 @@ bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int
|
|||||||
|
|
||||||
void Graphics::initCapabilities()
|
void Graphics::initCapabilities()
|
||||||
{
|
{
|
||||||
// todo
|
// fixme: unsure what the first few features are for.
|
||||||
capabilities.features[FEATURE_MULTI_RENDER_TARGET_FORMATS] = false;
|
capabilities.features[FEATURE_MULTI_RENDER_TARGET_FORMATS] = true;
|
||||||
capabilities.features[FEATURE_CLAMP_ZERO] = false;
|
capabilities.features[FEATURE_CLAMP_ZERO] = false;
|
||||||
capabilities.features[FEATURE_CLAMP_ONE] = false;
|
capabilities.features[FEATURE_CLAMP_ONE] = false;
|
||||||
capabilities.features[FEATURE_BLEND_MINMAX] = false;
|
capabilities.features[FEATURE_BLEND_MINMAX] = false;
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// löve
|
// löve
|
||||||
@@ -371,6 +391,7 @@ private:
|
|||||||
VkSampler createSampler(const SamplerState &samplerState);
|
VkSampler createSampler(const SamplerState &samplerState);
|
||||||
|
|
||||||
uint32_t vulkanApiVersion = VK_VERSION_1_0;
|
uint32_t vulkanApiVersion = VK_VERSION_1_0;
|
||||||
|
bool enableValidationLayers = false;
|
||||||
VkInstance instance = VK_NULL_HANDLE;
|
VkInstance instance = VK_NULL_HANDLE;
|
||||||
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||||||
int requestedMsaa = 0;
|
int requestedMsaa = 0;
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#include "GraphicsReadback.h"
|
#include "GraphicsReadback.h"
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graphics/GraphicsReadback.h"
|
#include "graphics/GraphicsReadback.h"
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// LÖVE
|
// LÖVE
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#include "ShaderStage.h"
|
#include "ShaderStage.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graphics/ShaderStage.h"
|
#include "graphics/ShaderStage.h"
|
||||||
|
|||||||
@@ -1,5 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#include "StreamBuffer.h"
|
#include "StreamBuffer.h"
|
||||||
#include "vulkan/vulkan.h"
|
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graphics/Volatile.h"
|
#include "graphics/Volatile.h"
|
||||||
#include "modules/graphics/StreamBuffer.h"
|
#include "graphics/StreamBuffer.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
|
|
||||||
#include "VulkanWrapper.h"
|
#include "VulkanWrapper.h"
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
#include "Vulkan.h"
|
#include "Vulkan.h"
|
||||||
@@ -15,6 +35,7 @@ Texture::Texture(love::graphics::Graphics *gfx, const Settings &settings, const
|
|||||||
: love::graphics::Texture(gfx, settings, data)
|
: love::graphics::Texture(gfx, settings, data)
|
||||||
, vgfx(dynamic_cast<Graphics*>(gfx))
|
, vgfx(dynamic_cast<Graphics*>(gfx))
|
||||||
, slices(settings.type)
|
, slices(settings.type)
|
||||||
|
, imageAspect(0)
|
||||||
{
|
{
|
||||||
if (data)
|
if (data)
|
||||||
slices = *data;
|
slices = *data;
|
||||||
@@ -27,6 +48,13 @@ bool Texture::loadVolatile()
|
|||||||
allocator = vgfx->getVmaAllocator();
|
allocator = vgfx->getVmaAllocator();
|
||||||
device = vgfx->getDevice();
|
device = vgfx->getDevice();
|
||||||
|
|
||||||
|
if (isPixelFormatDepthStencil(format))
|
||||||
|
imageAspect |= VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||||
|
else if (isPixelFormatDepth(format))
|
||||||
|
imageAspect |= VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||||
|
else
|
||||||
|
imageAspect |= VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
|
||||||
auto vulkanFormat = Vulkan::getTextureFormat(format);
|
auto vulkanFormat = Vulkan::getTextureFormat(format);
|
||||||
|
|
||||||
VkImageUsageFlags usageFlags =
|
VkImageUsageFlags usageFlags =
|
||||||
@@ -35,17 +63,20 @@ bool Texture::loadVolatile()
|
|||||||
|
|
||||||
if (readable)
|
if (readable)
|
||||||
{
|
{
|
||||||
usageFlags |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
if (!isPixelFormatDepthStencil(format))
|
||||||
|
usageFlags |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
|
|
||||||
if (!isPixelFormatCompressed(format))
|
if (!isPixelFormatCompressed(format) && !isPixelFormatDepthStencil(format))
|
||||||
usageFlags |= VK_IMAGE_USAGE_STORAGE_BIT;
|
usageFlags |= VK_IMAGE_USAGE_STORAGE_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPixelFormatDepthStencil(format) || isPixelFormatDepth(format))
|
|
||||||
usageFlags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
|
||||||
|
|
||||||
if (renderTarget)
|
if (renderTarget)
|
||||||
usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
{
|
||||||
|
if (isPixelFormatDepthStencil(format))
|
||||||
|
usageFlags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||||
|
else
|
||||||
|
usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
VkImageCreateFlags createFlags = 0;
|
VkImageCreateFlags createFlags = 0;
|
||||||
|
|
||||||
@@ -114,7 +145,7 @@ bool Texture::loadVolatile()
|
|||||||
|
|
||||||
for (int slice = 0; slice < sliceCount; slice++)
|
for (int slice = 0; slice < sliceCount; slice++)
|
||||||
{
|
{
|
||||||
auto* id = slices.get(slice, mip);
|
auto id = slices.get(slice, mip);
|
||||||
if (id != nullptr)
|
if (id != nullptr)
|
||||||
uploadImageData(id, mip, slice, 0, 0);
|
uploadImageData(id, mip, slice, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -125,7 +156,7 @@ bool Texture::loadVolatile()
|
|||||||
createTextureImageView();
|
createTextureImageView();
|
||||||
textureSampler = vgfx->getCachedSampler(samplerState);
|
textureSampler = vgfx->getCachedSampler(samplerState);
|
||||||
|
|
||||||
if (mipmapCount > 1 && getMipmapsMode() != MIPMAPS_NONE)
|
if (!isPixelFormatDepthStencil(format) && mipmapCount > 1 && getMipmapsMode() != MIPMAPS_NONE)
|
||||||
generateMipmaps();
|
generateMipmaps();
|
||||||
|
|
||||||
if (renderTarget)
|
if (renderTarget)
|
||||||
@@ -142,7 +173,7 @@ bool Texture::loadVolatile()
|
|||||||
viewInfo.image = textureImage;
|
viewInfo.image = textureImage;
|
||||||
viewInfo.viewType = Vulkan::getImageViewType(getTextureType());
|
viewInfo.viewType = Vulkan::getImageViewType(getTextureType());
|
||||||
viewInfo.format = vulkanFormat.internalFormat;
|
viewInfo.format = vulkanFormat.internalFormat;
|
||||||
viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
viewInfo.subresourceRange.aspectMask = imageAspect;
|
||||||
viewInfo.subresourceRange.baseMipLevel = mip;
|
viewInfo.subresourceRange.baseMipLevel = mip;
|
||||||
viewInfo.subresourceRange.levelCount = 1;
|
viewInfo.subresourceRange.levelCount = 1;
|
||||||
viewInfo.subresourceRange.baseArrayLayer = slice;
|
viewInfo.subresourceRange.baseArrayLayer = slice;
|
||||||
@@ -238,7 +269,7 @@ void Texture::createTextureImageView()
|
|||||||
viewInfo.image = textureImage;
|
viewInfo.image = textureImage;
|
||||||
viewInfo.viewType = Vulkan::getImageViewType(getTextureType());
|
viewInfo.viewType = Vulkan::getImageViewType(getTextureType());
|
||||||
viewInfo.format = vulkanFormat.internalFormat;
|
viewInfo.format = vulkanFormat.internalFormat;
|
||||||
viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
viewInfo.subresourceRange.aspectMask = imageAspect;
|
||||||
viewInfo.subresourceRange.baseMipLevel = 0;
|
viewInfo.subresourceRange.baseMipLevel = 0;
|
||||||
viewInfo.subresourceRange.levelCount = getMipmapCount();
|
viewInfo.subresourceRange.levelCount = getMipmapCount();
|
||||||
viewInfo.subresourceRange.baseArrayLayer = 0;
|
viewInfo.subresourceRange.baseArrayLayer = 0;
|
||||||
@@ -257,12 +288,7 @@ void Texture::clear()
|
|||||||
auto commandBuffer = vgfx->getCommandBufferForDataTransfer();
|
auto commandBuffer = vgfx->getCommandBufferForDataTransfer();
|
||||||
|
|
||||||
VkImageSubresourceRange range{};
|
VkImageSubresourceRange range{};
|
||||||
if (isPixelFormatDepthStencil(format))
|
range.aspectMask = imageAspect;
|
||||||
range.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
||||||
else if (isPixelFormatDepth(format))
|
|
||||||
range.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
|
||||||
else
|
|
||||||
range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
||||||
range.baseMipLevel = 0;
|
range.baseMipLevel = 0;
|
||||||
range.levelCount = VK_REMAINING_MIP_LEVELS;
|
range.levelCount = VK_REMAINING_MIP_LEVELS;
|
||||||
range.baseArrayLayer = 0;
|
range.baseArrayLayer = 0;
|
||||||
@@ -448,7 +474,7 @@ void Texture::uploadByteData(PixelFormat pixelformat, const void *data, size_t s
|
|||||||
else
|
else
|
||||||
baseLayer = slice;
|
baseLayer = slice;
|
||||||
|
|
||||||
region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
region.imageSubresource.aspectMask = imageAspect;
|
||||||
region.imageSubresource.mipLevel = level;
|
region.imageSubresource.mipLevel = level;
|
||||||
region.imageSubresource.baseArrayLayer = baseLayer;
|
region.imageSubresource.baseArrayLayer = baseLayer;
|
||||||
region.imageSubresource.layerCount = 1;
|
region.imageSubresource.layerCount = 1;
|
||||||
@@ -503,7 +529,7 @@ void Texture::copyFromBuffer(graphics::Buffer *source, size_t sourceoffset, int
|
|||||||
auto commandBuffer = vgfx->getCommandBufferForDataTransfer();
|
auto commandBuffer = vgfx->getCommandBufferForDataTransfer();
|
||||||
|
|
||||||
VkImageSubresourceLayers layers{};
|
VkImageSubresourceLayers layers{};
|
||||||
layers.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
layers.aspectMask = imageAspect;
|
||||||
layers.mipLevel = mipmap;
|
layers.mipLevel = mipmap;
|
||||||
layers.baseArrayLayer = slice;
|
layers.baseArrayLayer = slice;
|
||||||
layers.layerCount = 1;
|
layers.layerCount = 1;
|
||||||
@@ -533,7 +559,7 @@ void Texture::copyToBuffer(graphics::Buffer *dest, int slice, int mipmap, const
|
|||||||
auto commandBuffer = vgfx->getCommandBufferForDataTransfer();
|
auto commandBuffer = vgfx->getCommandBufferForDataTransfer();
|
||||||
|
|
||||||
VkImageSubresourceLayers layers{};
|
VkImageSubresourceLayers layers{};
|
||||||
layers.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
layers.aspectMask = imageAspect;
|
||||||
layers.mipLevel = mipmap;
|
layers.mipLevel = mipmap;
|
||||||
layers.baseArrayLayer = slice;
|
layers.baseArrayLayer = slice;
|
||||||
layers.layerCount = 1;
|
layers.layerCount = 1;
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graphics/Texture.h"
|
#include "graphics/Texture.h"
|
||||||
@@ -54,6 +74,7 @@ private:
|
|||||||
|
|
||||||
Graphics *vgfx = nullptr;
|
Graphics *vgfx = nullptr;
|
||||||
VkDevice device = VK_NULL_HANDLE;
|
VkDevice device = VK_NULL_HANDLE;
|
||||||
|
VkImageAspectFlags imageAspect;
|
||||||
VmaAllocator allocator = VK_NULL_HANDLE;
|
VmaAllocator allocator = VK_NULL_HANDLE;
|
||||||
VkImage textureImage = VK_NULL_HANDLE;
|
VkImage textureImage = VK_NULL_HANDLE;
|
||||||
VkImageLayout imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
VkImageLayout imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#include "Vulkan.h"
|
#include "Vulkan.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VK_NO_PROTOTYPES
|
#define VK_NO_PROTOTYPES
|
||||||
|
|||||||
Reference in New Issue
Block a user