Skip to content

Commit

Permalink
Convert to std::array and std::string. (Vulkan)
Browse files Browse the repository at this point in the history
Also mark a couple of global arrays as const.
  • Loading branch information
linuxdude42 committed Aug 29, 2020
1 parent 7ce7f55 commit 3061d79
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
23 changes: 13 additions & 10 deletions mythtv/libs/libmythui/vulkan/mythcombobuffervulkan.h
Expand Up @@ -7,19 +7,22 @@

#define MYTH_PUSHBUFFER_SIZE 112

// Total Buffer size of 112bytes.
// Vulkan spec guarantees 128 bytes for push constants
// Prevent clang-tidy modernize-avoid-c-arrays warnings.
extern "C" {
struct alignas(16) Buffer
{
float transform [16];
float position [4];
float texcoords [4];
float color [4];
};
}

class MythComboBufferVulkan
{
public:
// Total Buffer size of 112bytes.
// Vulkan spec guarantees 128 bytes for push constants
struct alignas(16) Buffer
{
float transform [16];
float position [4];
float texcoords [4];
float color [4];
};

MythComboBufferVulkan(float Width, float Height);

const void* Data(void) const;
Expand Down
12 changes: 6 additions & 6 deletions mythtv/libs/libmythui/vulkan/mythdebugvulkan.cpp
Expand Up @@ -5,11 +5,11 @@

#define LOC QString("VulkanMarker: ")

float MythDebugVulkan::s_DebugRed[4] = { 1.0, 0.0, 0.0, 1.0 };
float MythDebugVulkan::s_DebugGreen[4] = { 0.0, 1.0, 0.0, 1.0 };
float MythDebugVulkan::s_DebugBlue[4] = { 0.0, 0.0, 1.0, 1.0 };
float MythDebugVulkan::s_DebugGray[4] = { 0.5, 0.5, 0.5, 1.0 };
float MythDebugVulkan::s_DebugBlack[4] = { 0.0, 0.0, 0.0, 1.0 };
VulkanDebugColor const MythDebugVulkan::s_DebugRed { 1.0, 0.0, 0.0, 1.0 };
VulkanDebugColor const MythDebugVulkan::s_DebugGreen { 0.0, 1.0, 0.0, 1.0 };
VulkanDebugColor const MythDebugVulkan::s_DebugBlue { 0.0, 0.0, 1.0, 1.0 };
VulkanDebugColor const MythDebugVulkan::s_DebugGray { 0.5, 0.5, 0.5, 1.0 };
VulkanDebugColor const MythDebugVulkan::s_DebugBlack { 0.0, 0.0, 0.0, 1.0 };

MythDebugVulkan* MythDebugVulkan::Create(MythRenderVulkan *Render, VkDevice Device,
QVulkanDeviceFunctions *Functions, MythWindowVulkan *Window)
Expand Down Expand Up @@ -48,7 +48,7 @@ MythDebugVulkan::MythDebugVulkan(MythRenderVulkan *Render, VkDevice Device,
LOG(VB_GENERAL, LOG_INFO, LOC + "Failed to load procs");
}

void MythDebugVulkan::BeginRegion(VkCommandBuffer CmdBuffer, const char *Name, const float *Color)
void MythDebugVulkan::BeginRegion(VkCommandBuffer CmdBuffer, const char *Name, const VulkanDebugColor& Color)
{
VkDebugMarkerMarkerInfoEXT begin =
{ VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT, nullptr, Name,
Expand Down
14 changes: 8 additions & 6 deletions mythtv/libs/libmythui/vulkan/mythdebugvulkan.h
Expand Up @@ -5,20 +5,22 @@
#include "mythuiexp.h"
#include "vulkan/mythrendervulkan.h"

using VulkanDebugColor = std::array<float,4>;

class MUI_PUBLIC MythDebugVulkan : protected MythVulkanObject
{
public:
static float s_DebugRed[4];
static float s_DebugGreen[4];
static float s_DebugBlue[4];
static float s_DebugGray[4];
static float s_DebugBlack[4];
static const VulkanDebugColor s_DebugRed;
static const VulkanDebugColor s_DebugGreen;
static const VulkanDebugColor s_DebugBlue;
static const VulkanDebugColor s_DebugGray;
static const VulkanDebugColor s_DebugBlack;

static MythDebugVulkan* Create(MythRenderVulkan* Render, VkDevice Device,
QVulkanDeviceFunctions* Functions,
MythWindowVulkan* Window);

void BeginRegion (VkCommandBuffer CmdBuffer, const char* Name, const float *Color);
void BeginRegion (VkCommandBuffer CmdBuffer, const char* Name, const VulkanDebugColor& Color);
void EndRegion (VkCommandBuffer CmdBuffer);
void NameObject (uint64_t Object, VkDebugReportObjectTypeEXT Type, const char *Name);

Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythui/vulkan/mythrendervulkan.cpp
Expand Up @@ -258,8 +258,7 @@ void MythRenderVulkan::BeginFrame(void)
// clear the framebuffer
VkClearColorValue clearColor = {{ 0.0F, 0.0F, 0.0F, 1.0F }};
VkClearDepthStencilValue clearDS = { 1.0F, 0 };
VkClearValue clearValues[2];
memset(clearValues, 0, sizeof(clearValues));
std::array<VkClearValue,2> clearValues {};
clearValues[0].color = clearColor;
clearValues[1].depthStencil = clearDS;

Expand All @@ -272,7 +271,7 @@ void MythRenderVulkan::BeginFrame(void)
rpBeginInfo.renderPass = m_window->defaultRenderPass();
rpBeginInfo.framebuffer = m_window->currentFramebuffer();
rpBeginInfo.clearValueCount = 2;
rpBeginInfo.pClearValues = clearValues;
rpBeginInfo.pClearValues = clearValues.data();
rpBeginInfo.renderArea.extent.width = static_cast<uint32_t>(size.width());
rpBeginInfo.renderArea.extent.height = static_cast<uint32_t>(size.height());
m_devFuncs->vkCmdBeginRenderPass(commandbuffer, &rpBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
Expand Down

0 comments on commit 3061d79

Please sign in to comment.