59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
#include "../vulkan_state.h"
|
|
#include "../commands.h"
|
|
#include "materialsystem/imaterialsystem.h"
|
|
#include "tier0/platform.h"
|
|
#include "tier1/utlvector.h"
|
|
#include "vulkan/vulkan_core.h"
|
|
|
|
|
|
DECLARE_VULKAN_COMMAND(ClearColor)
|
|
{
|
|
|
|
CVkImage *pImg;
|
|
|
|
if (pImage)
|
|
pImg = (CVkImage*)pImage;
|
|
if (ppSwapchainImages)
|
|
pImg = (CVkImage*)ppSwapchainImages[iCurrentFrame];
|
|
|
|
if (pImg == NULL)
|
|
Plat_FatalErrorFunc("pImage and *ppSwapchainImages are NULL\n");
|
|
|
|
|
|
VkClearColorValue color = {.float32 = {r,g,b,a}};
|
|
VkImageSubresourceRange range = {
|
|
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
|
.levelCount = 1,
|
|
.layerCount = 1,
|
|
};
|
|
vkCmdClearColorImage(hCommandBuffer, pImg->m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &color, 1, &range);
|
|
}
|
|
|
|
DECLARE_VULKAN_COMMAND(Begin)
|
|
{
|
|
VkRenderingInfo stRenderingInfo = {};
|
|
CUtlVector<VkRenderingAttachmentInfo> attachments;
|
|
for (auto i: images)
|
|
{
|
|
VkRenderingAttachmentInfo a;
|
|
a.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
|
|
a.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
|
a.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
|
a.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
|
a.imageView = ((CVkImage*)VulkanGetObject(i.m_stImage, iCurrentFrame))->m_imageView;
|
|
attachments.AppendTail(a);
|
|
}
|
|
|
|
stRenderingInfo.sType = VK_STRUCTURE_TYPE_RENDERING_INFO;
|
|
stRenderingInfo.layerCount = 1;
|
|
stRenderingInfo.colorAttachmentCount = attachments.GetSize();
|
|
stRenderingInfo.pColorAttachments = attachments.GetData();
|
|
|
|
vkCmdBeginRendering(hCommandBuffer, &stRenderingInfo);
|
|
}
|
|
|
|
DECLARE_VULKAN_COMMAND(End)
|
|
{
|
|
vkCmdEndRendering(hCommandBuffer);
|
|
}
|