clear is here, draw is not

This commit is contained in:
2025-12-23 19:08:38 +02:00
parent 3b4e2eea32
commit fb5e607f88
8 changed files with 93 additions and 38 deletions

View File

@@ -4,6 +4,18 @@
#include "tier1/utlvector.h"
#include "vulkan_state.h"
BEGIN_VULKAN_COMMAND(Empty)
END_VULKAN_COMMAND(Empty)
BEGIN_VULKAN_COMMAND(Blit)
VkFrameObject_t stInputImage;
VkFrameObject_t stOutputImage;
int32_t iSrcMin[3];
int32_t iSrcMax[3];
int32_t iDstMin[3];
int32_t iDstMax[3];
END_VULKAN_COMMAND(Blit)
BEGIN_VULKAN_COMMAND(ClearColor)
float r;
float g;
@@ -42,20 +54,20 @@ BEGIN_VULKAN_COMMAND(DrawPrimitives)
END_VULKAN_COMMAND(DrawPrimitives)
BEGIN_VULKAN_COMMAND(SetScissors)
uint32_t uX;
uint32_t uY;
uint32_t uWidth;
uint32_t uHeight;
int32_t iX = 0;
int32_t iY = 0;
uint32_t uWidth = 0;
uint32_t uHeight = 0;
END_VULKAN_COMMAND(SetScissors)
BEGIN_VULKAN_COMMAND(SetViewport)
uint32_t uX;
uint32_t uY;
uint32_t uWidth;
uint32_t uHeight;
float fX = 0;
float fY = 0;
float fWidth = 0;
float fHeight = 0;
float fDepthMin = 0;
float fDepthMax = 1;
END_VULKAN_COMMAND(SetViewport)
BEGIN_VULKAN_COMMAND(Empty)
END_VULKAN_COMMAND(Empty)
#endif

View File

@@ -37,7 +37,8 @@ DECLARE_VULKAN_COMMAND(Begin)
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.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
a.clearValue.color.float32[1] = 1;
a.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
a.imageView = ((CVkImage*)VulkanGetObject(i.m_stImage, iCurrentFrame))->m_imageView;
attachments.AppendTail(a);
@@ -74,3 +75,31 @@ DECLARE_VULKAN_COMMAND(DrawPrimitives)
{
vkCmdDraw(hCommandBuffer, nVertexCount, nInstanceCount, nFirstVertex, nFirstInstance);
}
DECLARE_VULKAN_COMMAND(SetScissors)
{
VkRect2D r = {
.offset = {
iX,
iY,
},
.extent = {
uWidth,
uHeight,
},
};
vkCmdSetScissorWithCount(hCommandBuffer, 1, &r);
}
DECLARE_VULKAN_COMMAND(SetViewport)
{
VkViewport v = {
fX,
fY,
fWidth,
fHeight,
fDepthMin,
fDepthMax
};
vkCmdSetViewportWithCount(hCommandBuffer, 1, &v);
}

View File

@@ -0,0 +1,28 @@
#include "../vulkan_state.h"
#include "../commands.h"
#include "materialsystem/imaterialsystem.h"
#include "tier0/platform.h"
#include "tier1/utlvector.h"
DECLARE_VULKAN_COMMAND(Blit)
{
CVkImage *pVkInputImage = (CVkImage*)VulkanGetObject(stInputImage, iCurrentFrame);
CVkImage *pVkOutputImage = (CVkImage*)VulkanGetObject(stOutputImage, iCurrentFrame);
VkImageBlit stBlit = {
.srcSubresource = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.layerCount = 1,
},
.dstSubresource = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.layerCount = 1,
},
};
stBlit.srcOffsets[0].x = iSrcMin[0];
stBlit.srcOffsets[0].y = iSrcMin[1];
stBlit.srcOffsets[0].z = iSrcMin[2];
stBlit.srcOffsets[1].x = iSrcMax[0];
stBlit.srcOffsets[1].y = iSrcMax[1];
stBlit.srcOffsets[1].z = iSrcMax[2];
vkCmdBlitImage(hCommandBuffer, pVkInputImage->m_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, pVkOutputImage->m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &stBlit, VK_FILTER_NEAREST)
}

View File

@@ -1,5 +1,5 @@
#include "../vulkan_state.h"
#include "../raster_libraries.h"
#include "../libraries.h"
#include "tier1/utlbuffer.h"
#include "tier1/utlvector.h"
#include "tier2/ifilesystem.h"
@@ -221,13 +221,6 @@ BEGIN_BUILD_PIPELINE_LIBRARY(PixelShader)
pipeline.pStages = &shader;
depthStencil.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
depthStencil.minDepthBounds = 0;
depthStencil.maxDepthBounds = 1;
depthStencil.depthTestEnable = VK_TRUE;
depthStencil.depthWriteEnable = VK_TRUE;
depthStencil.depthBoundsTestEnable = VK_FALSE;
depthStencil.stencilTestEnable = VK_FALSE;
depthStencil.depthCompareOp = VK_COMPARE_OP_LESS;
pipeline.pDepthStencilState = &depthStencil;
skipshader:
@@ -258,25 +251,12 @@ BEGIN_BUILD_PIPELINE_LIBRARY(PixelOutput)
render.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT;;
depthStencil.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
depthStencil.minDepthBounds = 0;
depthStencil.maxDepthBounds = 1;
depthStencil.depthTestEnable = VK_TRUE;
depthStencil.depthWriteEnable = VK_TRUE;
depthStencil.depthBoundsTestEnable = VK_FALSE;
depthStencil.stencilTestEnable = VK_FALSE;
depthStencil.depthCompareOp = VK_COMPARE_OP_LESS;
for ( auto e: m_eFormats )
{
VkPipelineColorBlendAttachmentState a = {};
a.blendEnable = VK_TRUE;
a.blendEnable = VK_TRUE;
a.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
a.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
a.colorBlendOp = VK_BLEND_OP_ADD;
a.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
a.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
a.alphaBlendOp = VK_BLEND_OP_ADD;
a.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
a.blendEnable = VK_FALSE;
attachments.AppendTail(a);
}
blend.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;

View File

@@ -85,7 +85,13 @@ void CVkRenderCommandList::SetMaterial( IMaterial *pMaterial )
m_pCurrentMaterialBuffer->AddCommand(pSetShader);
CVkSetScissorsCommand *pScissorsCommand = CREATE_COMMAND(SetScissors);
pScissorsCommand->uWidth = 1280;
pScissorsCommand->uHeight = 720;
m_pCurrentMaterialBuffer->AddCommand(pScissorsCommand);
CVkSetViewportCommand *pViewportCommand = CREATE_COMMAND(SetViewport);
pViewportCommand->fWidth = 1280;
pViewportCommand->fHeight = 720;
m_pCurrentMaterialBuffer->AddCommand(pViewportCommand);
}
}

View File

@@ -10,7 +10,7 @@
#include "vulkan/vulkan_core.h"
#include "vulkan_state.h"
#include "igamewindow.h"
#include "raster_libraries.h"
#include "libraries.h"
#define REQUIRED_EXTENSION(ext) ext##_EXTENSION_NAME,