Merge branch 'postprocessing'

This commit is contained in:
Connor McLaughlin
2020-09-13 12:14:21 +10:00
54 changed files with 2894 additions and 612 deletions

View File

@ -121,6 +121,8 @@ void Texture::Destroy()
m_rtv.Reset();
m_srv.Reset();
m_texture.Reset();
m_width = 0;
m_height = 0;
}
} // namespace D3D11

View File

@ -10,11 +10,8 @@ namespace Common {
template<typename T>
struct Rectangle
{
enum : T
{
InvalidMinCoord = std::numeric_limits<T>::max(),
InvalidMaxCoord = std::numeric_limits<T>::min()
};
static constexpr T InvalidMinCoord = std::numeric_limits<T>::max();
static constexpr T InvalidMaxCoord = std::numeric_limits<T>::min();
/// Default constructor - initializes to an invalid coordinate range suitable for including points.
constexpr Rectangle() : left(InvalidMinCoord), top(InvalidMinCoord), right(InvalidMaxCoord), bottom(InvalidMaxCoord)

View File

@ -166,6 +166,11 @@ String::String(String&& moveString)
Assign(moveString);
}
String::String(const std::string_view& sv)
{
AppendString(sv.data(), static_cast<u32>(sv.size()));
}
String::~String()
{
StringDataRelease(m_pStringData);

View File

@ -54,6 +54,9 @@ public:
// Construct a string from a data object, does not increment the reference count on the string data, use carefully.
explicit String(StringData* pStringData) : m_pStringData(pStringData) {}
// Creates string from string_view.
String(const std::string_view& sv);
// Destructor. Child classes may not have any destructors, as this is not virtual.
~String();
@ -307,6 +310,12 @@ public:
Assign(copyString.GetCharArray());
}
StackString(const std::string_view& sv) : String(&m_sStringData)
{
InitStackStringData();
AppendString(sv.data(), static_cast<u32>(sv.size()));
}
// Override the fromstring method
static StackString FromFormat(const char* FormatString, ...)
{

View File

@ -91,7 +91,7 @@ bool Context::CheckValidationLayerAvailablility()
return strcmp(it.extensionName, VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0;
}) != extension_list.end() &&
std::find_if(layer_list.begin(), layer_list.end(), [](const auto& it) {
return strcmp(it.layerName, "VK_LAYER_LUNARG_standard_validation") == 0;
return strcmp(it.layerName, "VK_LAYER_KHRONOS_validation") == 0;
}) != layer_list.end());
}
@ -123,7 +123,7 @@ VkInstance Context::CreateVulkanInstance(bool enable_surface, bool enable_debug_
// Enable debug layer on debug builds
if (enable_validation_layer)
{
static const char* layer_names[] = {"VK_LAYER_LUNARG_standard_validation"};
static const char* layer_names[] = {"VK_LAYER_KHRONOS_validation"};
instance_create_info.enabledLayerCount = 1;
instance_create_info.ppEnabledLayerNames = layer_names;
}
@ -997,6 +997,12 @@ void Context::DeferImageViewDestruction(VkImageView object)
resources.cleanup_resources.push_back([this, object]() { vkDestroyImageView(m_device, object, nullptr); });
}
void Context::DeferPipelineDestruction(VkPipeline pipeline)
{
FrameResources& resources = m_frame_resources[m_current_frame];
resources.cleanup_resources.push_back([this, pipeline]() { vkDestroyPipeline(m_device, pipeline, nullptr); });
}
static VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT flags,
VkDebugReportObjectTypeEXT objectType, uint64_t object,
size_t location, int32_t messageCode,

View File

@ -163,6 +163,7 @@ public:
void DeferFramebufferDestruction(VkFramebuffer object);
void DeferImageDestruction(VkImage object);
void DeferImageViewDestruction(VkImageView object);
void DeferPipelineDestruction(VkPipeline pipeline);
// Wait for a fence to be completed.
// Also invokes callbacks for completion.

View File

@ -31,7 +31,7 @@ public:
ALWAYS_INLINE VkSurfaceKHR GetSurface() const { return m_surface; }
ALWAYS_INLINE VkSurfaceFormatKHR GetSurfaceFormat() const { return m_surface_format; }
ALWAYS_INLINE VkFormat GetTextureFormat() const { return m_texture_format; }
ALWAYS_INLINE VkFormat GetTextureFormat() const { return m_surface_format.format; }
ALWAYS_INLINE bool IsVSyncEnabled() const { return m_vsync_enabled; }
ALWAYS_INLINE VkSwapchainKHR GetSwapChain() const { return m_swap_chain; }
ALWAYS_INLINE u32 GetWidth() const { return m_width; }
@ -85,7 +85,6 @@ private:
VkSurfaceKHR m_surface = VK_NULL_HANDLE;
VkSurfaceFormatKHR m_surface_format = {};
VkPresentModeKHR m_present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR;
VkFormat m_texture_format = VK_FORMAT_UNDEFINED;
VkRenderPass m_load_render_pass = VK_NULL_HANDLE;
VkRenderPass m_clear_render_pass = VK_NULL_HANDLE;