Started work on build system
This commit is contained in:
@@ -16,7 +16,6 @@ void engine_build(struct build_data b)
|
|||||||
|
|
||||||
/* rendering */
|
/* rendering */
|
||||||
"engine/vk_video.cpp",
|
"engine/vk_video.cpp",
|
||||||
"engine/vk_brush.cpp",
|
|
||||||
"engine/vk_mesh.cpp",
|
"engine/vk_mesh.cpp",
|
||||||
szVideoFile,
|
szVideoFile,
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,49 @@
|
|||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "cglm/mat4.h"
|
#include "cglm/mat4.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
|
||||||
CUtlSelfReferencingVector<CBaseEntity*> g_entities;
|
CUtlSelfReferencingVector<CBaseEntity*> g_entities;
|
||||||
CUtlVector<CEntityRegistry*> g_RegisteredEntities;
|
CUtlVector<CEntityRegistry*> g_RegisteredEntities;
|
||||||
|
|
||||||
CBaseEntity::CBaseEntity()
|
CBaseEntity::CBaseEntity()
|
||||||
{
|
{
|
||||||
glm_mat4_identity(m_matrix);
|
glm_mat3_identity(m_matrix);
|
||||||
|
glm_vec3_zero(m_position);
|
||||||
|
glm_vec3_zero(m_scale);
|
||||||
};
|
};
|
||||||
|
void CBaseEntity::ReadParameter( const char *szName, const char *szValue )
|
||||||
|
{
|
||||||
|
CUtlString name = szName;
|
||||||
|
if (name == "origin")
|
||||||
|
V_sscanf(szValue, "%f %f %f", &m_position[0], &m_position[1], &m_position[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBaseEntity::SetPosition( vec3 position )
|
||||||
|
{
|
||||||
|
V_memcpy(m_position, position, sizeof(vec3));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBaseEntity::SetRotationEuler( vec3 euler )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBaseEntity::SetRotationQuat( vec4 quaternion )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBaseEntity::SetRotationMatrix( mat3 matrix )
|
||||||
|
{
|
||||||
|
V_memcpy(m_matrix, matrix, sizeof(mat3));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBaseEntity::SetScale( vec3 scale )
|
||||||
|
{
|
||||||
|
V_memcpy(m_scale, scale, sizeof(vec3));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CEntityRegistry::CEntityRegistry(const char *szName, const char *szClass, EntityRegistryFn pfn) :
|
CEntityRegistry::CEntityRegistry(const char *szName, const char *szClass, EntityRegistryFn pfn) :
|
||||||
m_szName(szName), m_szClass(szClass), m_pfn(pfn), m_pClientfn(0)
|
m_szName(szName), m_szClass(szClass), m_pfn(pfn), m_pClientfn(0)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "brush.h"
|
#include "brush.h"
|
||||||
|
#include "baseentity.h"
|
||||||
|
#include "cglm/mat4.h"
|
||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
#include "rendering.h"
|
#include "rendering.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
@@ -12,11 +14,13 @@ void CBrushEntity::Precache()
|
|||||||
|
|
||||||
void CBrushEntity::Spawn()
|
void CBrushEntity::Spawn()
|
||||||
{
|
{
|
||||||
|
/* physics don't support unindexed meshes, so generate indicies */
|
||||||
CUtlBuffer<uint32_t> indicies(m_mesh.GetSize()*3);
|
CUtlBuffer<uint32_t> indicies(m_mesh.GetSize()*3);
|
||||||
for (uint32_t i = 0;i<indicies.GetSize();i++)
|
for (uint32_t i = 0;i<indicies.GetSize();i++)
|
||||||
{
|
{
|
||||||
indicies[i]=i;
|
indicies[i]=i;
|
||||||
}
|
}
|
||||||
|
/* copy over the triangles to a separate buffer, which will be used by physics */
|
||||||
CUtlBuffer<Point<float>> triangles(m_mesh.GetSize()*3);
|
CUtlBuffer<Point<float>> triangles(m_mesh.GetSize()*3);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
for (auto tri: m_mesh)
|
for (auto tri: m_mesh)
|
||||||
@@ -24,17 +28,10 @@ void CBrushEntity::Spawn()
|
|||||||
V_memcpy(&triangles[i],tri.location,36);
|
V_memcpy(&triangles[i],tri.location,36);
|
||||||
i+=3;
|
i+=3;
|
||||||
}
|
}
|
||||||
|
/* use them */
|
||||||
px_collider_params params = {};
|
px_collider_params params = {};
|
||||||
params.friction = 0.6;
|
params.friction = 0.6;
|
||||||
m_collider = px_trimesh((Point<float>*)triangles.GetMemory(), triangles.GetSize(), (uint32_t(*)[3])indicies.GetMemory(), indicies.GetSize()/3 ,params);
|
m_collider = px_trimesh((Point<float>*)triangles.GetMemory(), triangles.GetSize(), (uint32_t(*)[3])indicies.GetMemory(), indicies.GetSize()/3 ,params);
|
||||||
//m_collider = px_box(4, 10, 1, params);
|
|
||||||
px_matrix mat = {};
|
|
||||||
mat.m[0] = 1;
|
|
||||||
mat.m[5] = 1;
|
|
||||||
mat.m[10] = 1;
|
|
||||||
mat.m[15] = 1;
|
|
||||||
px_rigidbody_params param = {};
|
|
||||||
param.gravity_scale = 1;
|
|
||||||
px_fixedbody(px, m_collider);
|
px_fixedbody(px, m_collider);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,6 +41,12 @@ void CBrushEntity::Destroy()
|
|||||||
}
|
}
|
||||||
void CBrushEntity::Think( float fDelta )
|
void CBrushEntity::Think( float fDelta )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void CBrushEntity::ReadParameter( const char *szName, const char *szValue )
|
||||||
|
{
|
||||||
|
CBaseEntity::ReadParameter(szName, szValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +92,7 @@ void C_BrushEntity::Spawn()
|
|||||||
}
|
}
|
||||||
vertexBuffer->Unmap();
|
vertexBuffer->Unmap();
|
||||||
|
|
||||||
mesh = IBrushRenderer::CreateMesh();
|
mesh = IMeshRenderer::CreateMesh();
|
||||||
mesh->SetVertexBuffer(vertexBuffer);
|
mesh->SetVertexBuffer(vertexBuffer);
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -102,7 +105,16 @@ void C_BrushEntity::Think( float fDelta )
|
|||||||
{
|
{
|
||||||
material.m.albedo = ITextureManager::GetTexture(pAlbedo);
|
material.m.albedo = ITextureManager::GetTexture(pAlbedo);
|
||||||
IRenderer::SetMaterial(&material);
|
IRenderer::SetMaterial(&material);
|
||||||
|
mat4 matrix;
|
||||||
|
glm_mat4_zero(matrix);
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
matrix[i/3][i%3] = pEntity->m_matrix[i/3][i%3];
|
||||||
|
}
|
||||||
|
matrix[3][3] = 1;
|
||||||
|
matrix[3][0] = pEntity->m_position[0];
|
||||||
|
matrix[3][1] = pEntity->m_position[1];
|
||||||
|
matrix[3][2] = pEntity->m_position[2];
|
||||||
|
mesh->SetMatrix(matrix);
|
||||||
mesh->Draw();
|
mesh->Draw();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ public:
|
|||||||
virtual void Spawn( void ) override;
|
virtual void Spawn( void ) override;
|
||||||
virtual void Destroy( void ) override;
|
virtual void Destroy( void ) override;
|
||||||
virtual void Think( float fDelta ) override;
|
virtual void Think( float fDelta ) override;
|
||||||
IVertexBuffer *vertexBuffer;
|
|
||||||
IMesh *mesh;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void C_Light::Precache()
|
void C_Light::Precache()
|
||||||
@@ -19,56 +17,7 @@ void C_Light::Precache()
|
|||||||
|
|
||||||
void C_Light::Spawn()
|
void C_Light::Spawn()
|
||||||
{
|
{
|
||||||
float cubeVertices[] = {
|
|
||||||
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
||||||
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
|
|
||||||
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
|
|
||||||
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
|
|
||||||
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
|
|
||||||
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
||||||
|
|
||||||
-0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
|
|
||||||
-0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
|
||||||
0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
|
|
||||||
-0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
|
|
||||||
|
|
||||||
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
||||||
-0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
|
||||||
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
||||||
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
||||||
|
|
||||||
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
||||||
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
|
||||||
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
||||||
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
||||||
|
|
||||||
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f,
|
|
||||||
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
||||||
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
||||||
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
|
||||||
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
|
|
||||||
-0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
|
|
||||||
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
||||||
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
||||||
-0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
|
|
||||||
-0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
|
|
||||||
};
|
|
||||||
vertexBuffer = IRenderer::CreateVertexBuffer(sizeof(cubeVertices));
|
|
||||||
void *pTriangles = vertexBuffer->Map();
|
|
||||||
V_memcpy(pTriangles, cubeVertices, sizeof(cubeVertices));
|
|
||||||
vertexBuffer->Unmap();
|
|
||||||
|
|
||||||
mesh = IMeshRenderer::CreateMesh();
|
|
||||||
mesh->SetVertexBuffer(vertexBuffer);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void C_Light::Destroy()
|
void C_Light::Destroy()
|
||||||
@@ -77,9 +26,7 @@ void C_Light::Destroy()
|
|||||||
}
|
}
|
||||||
void C_Light::Think( float fDelta )
|
void C_Light::Think( float fDelta )
|
||||||
{
|
{
|
||||||
IRenderer::SetMaterial(0);
|
|
||||||
mesh->SetMatrix(pEntity->m_matrix);
|
|
||||||
mesh->Draw();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LINK_CLIENT_ENTITY(C_Light, CLight)
|
LINK_CLIENT_ENTITY(C_Light, CLight)
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ void ILevel::LoadLevel( const char *szLevelName )
|
|||||||
CUtlBuffer<char> szParamValue(V_strlen(pData)+1);
|
CUtlBuffer<char> szParamValue(V_strlen(pData)+1);
|
||||||
V_strcpy(szParamValue, pData);
|
V_strcpy(szParamValue, pData);
|
||||||
pData+=szParamValue.GetSize();
|
pData+=szParamValue.GetSize();
|
||||||
|
pEntity->ReadParameter(szParamName, szParamValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
CBrushEntity *pBrush = dynamic_cast<CBrushEntity*>(pEntity);
|
CBrushEntity *pBrush = dynamic_cast<CBrushEntity*>(pEntity);
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ class CLight: public CBaseEntity
|
|||||||
public:
|
public:
|
||||||
virtual void Precache ( void ) override;
|
virtual void Precache ( void ) override;
|
||||||
virtual void Spawn( void ) override;
|
virtual void Spawn( void ) override;
|
||||||
|
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||||
virtual void Destroy( void ) override;
|
virtual void Destroy( void ) override;
|
||||||
virtual void Think( float fDelta ) override;
|
virtual void Think( float fDelta ) override;
|
||||||
private:
|
|
||||||
Collider* col;
|
|
||||||
RigidBodyHandle *m_body;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void CLight::Precache()
|
void CLight::Precache()
|
||||||
@@ -22,31 +20,22 @@ void CLight::Precache()
|
|||||||
|
|
||||||
void CLight::Spawn()
|
void CLight::Spawn()
|
||||||
{
|
{
|
||||||
px_collider_params params = {};
|
|
||||||
params.friction = 0.7;
|
|
||||||
col = px_box(0.5,0.5,0.5, params);
|
|
||||||
px_matrix mat = {};
|
|
||||||
mat.m[0] = 1;
|
|
||||||
mat.m[5] = 1;
|
|
||||||
mat.m[10] = 1;
|
|
||||||
mat.m[15] = 1;
|
|
||||||
mat.m[11]=10;
|
|
||||||
mat.m[7]=-4;
|
|
||||||
mat.m[3]=12;
|
|
||||||
px_rigidbody_params param = {};
|
|
||||||
param.gravity_scale = 1;
|
|
||||||
m_body=px_rigidbody(px, col, mat, param);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void CLight::ReadParameter( const char *szName, const char *szValue )
|
||||||
|
{
|
||||||
|
CBaseEntity::ReadParameter(szName, szValue);
|
||||||
|
}
|
||||||
|
|
||||||
void CLight::Destroy()
|
void CLight::Destroy()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void CLight::Think( float fDelta )
|
void CLight::Think( float fDelta )
|
||||||
{
|
{
|
||||||
px_matrix pos = px_getmatrix(px, m_body);
|
|
||||||
V_memcpy(m_matrix, pos.m, 64);
|
|
||||||
V_printf("%p %f %f %f\n",col, pos.m[12], pos.m[13], pos.m[14]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_ENTITY(light, CLight)
|
DECLARE_ENTITY(light, CLight)
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ class CWorldSpawn: public CBrushEntity
|
|||||||
public:
|
public:
|
||||||
virtual void Precache ( void ) override;
|
virtual void Precache ( void ) override;
|
||||||
virtual void Spawn( void ) override;
|
virtual void Spawn( void ) override;
|
||||||
|
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||||
virtual void Destroy( void ) override;
|
virtual void Destroy( void ) override;
|
||||||
virtual void Think( float fDelta ) override;
|
virtual void Think( float fDelta ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
void CWorldSpawn::Precache()
|
void CWorldSpawn::Precache()
|
||||||
@@ -17,17 +18,22 @@ void CWorldSpawn::Precache()
|
|||||||
|
|
||||||
void CWorldSpawn::Spawn()
|
void CWorldSpawn::Spawn()
|
||||||
{
|
{
|
||||||
V_printf("Cool\n");
|
|
||||||
CBrushEntity::Spawn();
|
CBrushEntity::Spawn();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void CWorldSpawn::ReadParameter( const char *szName, const char *szValue )
|
||||||
|
{
|
||||||
|
CBrushEntity::ReadParameter(szName, szValue);
|
||||||
|
}
|
||||||
|
|
||||||
void CWorldSpawn::Destroy()
|
void CWorldSpawn::Destroy()
|
||||||
{
|
{
|
||||||
CBrushEntity::Destroy();
|
CBrushEntity::Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorldSpawn::Think( float fDelta )
|
void CWorldSpawn::Think( float fDelta )
|
||||||
{
|
{
|
||||||
CBrushEntity::Think(fDelta);
|
CBrushEntity::Think(fDelta);
|
||||||
};
|
}
|
||||||
|
|
||||||
DECLARE_ENTITY(worldspawn, CWorldSpawn)
|
DECLARE_ENTITY(worldspawn, CWorldSpawn)
|
||||||
|
|||||||
@@ -1,316 +0,0 @@
|
|||||||
#include "filesystem.h"
|
|
||||||
#include "rendering.h"
|
|
||||||
#include "tier1/utlvector.h"
|
|
||||||
#include "vk_helper.h"
|
|
||||||
#include "vulkan/vulkan_core.h"
|
|
||||||
|
|
||||||
|
|
||||||
vk_tripipeline_t g_brushPipeline = {};
|
|
||||||
|
|
||||||
VkDescriptorPool g_brushDescriptorPool;
|
|
||||||
VkDescriptorSet g_brushDescriptorSet;
|
|
||||||
|
|
||||||
VkSampler g_brushSampler;
|
|
||||||
|
|
||||||
|
|
||||||
abstract_class CBrush: public IBrush
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void SetVertexBuffer( IVertexBuffer *pBuffer ) override;
|
|
||||||
void SetIndexBuffer( IIndexBuffer *pBuffer ) override;
|
|
||||||
void Draw() override;
|
|
||||||
|
|
||||||
Material_t m_material;
|
|
||||||
CVertexBuffer *m_pVertexBuffer = NULL;
|
|
||||||
CIndexBuffer *m_pIndexBuffer = NULL;
|
|
||||||
};
|
|
||||||
CUtlVector<CBrush> g_drawnBrushes;
|
|
||||||
|
|
||||||
|
|
||||||
void CBrush::SetVertexBuffer( IVertexBuffer *pBuffer )
|
|
||||||
{
|
|
||||||
m_pVertexBuffer = (CVertexBuffer*)pBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBrush::SetIndexBuffer( IIndexBuffer *pBuffer )
|
|
||||||
{
|
|
||||||
m_pIndexBuffer = (CIndexBuffer*)pBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBrush::Draw()
|
|
||||||
{
|
|
||||||
if (!g_pCurrentMaterial)
|
|
||||||
m_material = {};
|
|
||||||
else
|
|
||||||
m_material = g_pCurrentMaterial->m;
|
|
||||||
g_drawnBrushes.AppendTail(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void IBrushRenderer::Init()
|
|
||||||
{
|
|
||||||
CUtlVector<vk_shader_t> shaders(2);
|
|
||||||
for (auto &shader: shaders)
|
|
||||||
{
|
|
||||||
shader.m_shaderModule = NULL;
|
|
||||||
}
|
|
||||||
shaders[0].Create("gfx/brush_vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
|
||||||
shaders[1].Create("gfx/brush_frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
|
||||||
CUtlVector<VkDescriptorSetLayoutBinding> bindings(2);
|
|
||||||
bindings[0] = {};
|
|
||||||
bindings[0].binding = 0;
|
|
||||||
bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
|
||||||
bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
|
||||||
bindings[0].descriptorCount = 1;
|
|
||||||
bindings[1] = {};
|
|
||||||
bindings[1].binding = 1;
|
|
||||||
bindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
|
||||||
bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
|
||||||
bindings[1].descriptorCount = 1024;
|
|
||||||
g_brushPipeline.Create(shaders, bindings, 4);
|
|
||||||
shaders[1].Destroy();
|
|
||||||
shaders[0].Destroy();
|
|
||||||
|
|
||||||
CUtlVector<VkDescriptorPoolSize> pools;
|
|
||||||
for (auto &binding: bindings)
|
|
||||||
{
|
|
||||||
VkDescriptorPoolSize dps = {};
|
|
||||||
dps.type = binding.descriptorType;
|
|
||||||
dps.descriptorCount = binding.descriptorCount;
|
|
||||||
pools.AppendTail(dps);
|
|
||||||
}
|
|
||||||
|
|
||||||
VkDescriptorPoolCreateInfo poolInfo = {};
|
|
||||||
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
|
||||||
poolInfo.poolSizeCount = pools.GetSize();
|
|
||||||
poolInfo.pPoolSizes = pools.GetData();
|
|
||||||
poolInfo.maxSets = 1;
|
|
||||||
vkCreateDescriptorPool(g_vkDevice, &poolInfo, NULL, &g_brushDescriptorPool);
|
|
||||||
|
|
||||||
VkDescriptorSetAllocateInfo allocInfo = {};
|
|
||||||
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
|
||||||
allocInfo.descriptorPool = g_brushDescriptorPool;
|
|
||||||
allocInfo.descriptorSetCount = 1;
|
|
||||||
allocInfo.pSetLayouts = &g_brushPipeline.m_descriptorSetLayout;
|
|
||||||
vkAllocateDescriptorSets(g_vkDevice, &allocInfo, &g_brushDescriptorSet);
|
|
||||||
|
|
||||||
|
|
||||||
VkPhysicalDeviceProperties properties{};
|
|
||||||
vkGetPhysicalDeviceProperties(g_vkPhysicalDevice, &properties);
|
|
||||||
VkSamplerCreateInfo samplerInfo{};
|
|
||||||
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
|
||||||
samplerInfo.magFilter = VK_FILTER_LINEAR;
|
|
||||||
samplerInfo.minFilter = VK_FILTER_LINEAR;
|
|
||||||
samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
|
||||||
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
|
||||||
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
|
||||||
samplerInfo.anisotropyEnable = VK_FALSE;
|
|
||||||
samplerInfo.maxAnisotropy = properties.limits.maxSamplerAnisotropy;
|
|
||||||
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
|
|
||||||
samplerInfo.unnormalizedCoordinates = VK_FALSE;
|
|
||||||
samplerInfo.compareEnable = VK_FALSE;
|
|
||||||
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
|
|
||||||
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
|
|
||||||
samplerInfo.mipLodBias = 0.0f;
|
|
||||||
samplerInfo.minLod = 0.0f;
|
|
||||||
samplerInfo.maxLod = 0.0f;
|
|
||||||
vkCreateSampler(g_vkDevice, &samplerInfo, nullptr, &g_brushSampler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IBrushRenderer::Frame( float fDelta )
|
|
||||||
{
|
|
||||||
|
|
||||||
CUtlVector<VkWriteDescriptorSet> writes(2);
|
|
||||||
for (auto &write: writes)
|
|
||||||
{
|
|
||||||
write = {};
|
|
||||||
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
||||||
write.dstSet = g_brushDescriptorSet;
|
|
||||||
write.dstArrayElement = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkDescriptorBufferInfo bufferInfo = {};
|
|
||||||
bufferInfo.buffer = g_cameraProperties.m_buffer;
|
|
||||||
bufferInfo.offset = 0;
|
|
||||||
bufferInfo.range = g_cameraProperties.m_nSize;
|
|
||||||
writes[0].dstBinding = 0;
|
|
||||||
writes[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
|
||||||
writes[0].descriptorCount = 1;
|
|
||||||
writes[0].pBufferInfo = &bufferInfo;
|
|
||||||
|
|
||||||
CUtlVector<VkDescriptorImageInfo> textures;
|
|
||||||
textures.Reserve(g_textures.GetSize());
|
|
||||||
for (ITexture *t: g_textures)
|
|
||||||
{
|
|
||||||
CTexture *texture = (CTexture*)t;
|
|
||||||
VkDescriptorImageInfo image = {};
|
|
||||||
image.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
|
||||||
image.imageView = texture->image.m_imageView;
|
|
||||||
image.sampler = g_brushSampler;
|
|
||||||
textures.AppendTail(image);
|
|
||||||
};
|
|
||||||
textures[0].sampler = g_invalidTextureSampler;
|
|
||||||
writes[1].dstBinding = 1;
|
|
||||||
writes[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
|
||||||
writes[1].descriptorCount = textures.GetSize();
|
|
||||||
writes[1].pImageInfo = textures.GetData();
|
|
||||||
vkUpdateDescriptorSets(g_vkDevice, writes.GetSize(), writes.GetData(), 0, NULL);
|
|
||||||
|
|
||||||
|
|
||||||
VkImageMemoryBarrier barrier = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
|
||||||
.srcAccessMask = 0,
|
|
||||||
.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
|
||||||
.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
|
||||||
.image = g_swapchainImage,
|
|
||||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
|
||||||
};
|
|
||||||
vkCmdPipelineBarrier(g_vkCommandBuffer,
|
|
||||||
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
|
||||||
0, 0, NULL, 0, NULL, 1, &barrier);
|
|
||||||
|
|
||||||
VkRenderingAttachmentInfo colorAttachment = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
|
||||||
.imageView = g_swapchainImageView,
|
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
|
||||||
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
|
||||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
|
||||||
.clearValue = {.color = {0.0f, 0.0f, 0.0f, 1.0f}}
|
|
||||||
};
|
|
||||||
VkRenderingAttachmentInfo depthAttachment = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
|
||||||
.imageView = g_meshdepth.m_imageView,
|
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
|
||||||
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
|
||||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
|
||||||
.clearValue = {.depthStencil = {.depth = 1}},
|
|
||||||
};
|
|
||||||
|
|
||||||
VkRenderingInfo renderInfo = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
|
|
||||||
.renderArea = {{0, 0}, {g_nWindowWidth, g_nWindowHeight}},
|
|
||||||
.layerCount = 1,
|
|
||||||
.colorAttachmentCount = 1,
|
|
||||||
.pColorAttachments = &colorAttachment,
|
|
||||||
.pDepthAttachment = &depthAttachment,
|
|
||||||
};
|
|
||||||
vkCmdBeginRendering(g_vkCommandBuffer, &renderInfo);
|
|
||||||
|
|
||||||
vkCmdSetRasterizerDiscardEnable(g_vkCommandBuffer, VK_FALSE);
|
|
||||||
vkCmdSetDepthBiasEnable(g_vkCommandBuffer, VK_FALSE);
|
|
||||||
_vkCmdSetPolygonModeEXT(g_vkCommandBuffer, VK_POLYGON_MODE_FILL);
|
|
||||||
vkCmdSetCullMode(g_vkCommandBuffer, VK_CULL_MODE_BACK_BIT);
|
|
||||||
vkCmdSetFrontFace(g_vkCommandBuffer, VK_FRONT_FACE_COUNTER_CLOCKWISE);
|
|
||||||
|
|
||||||
vkCmdSetDepthTestEnable(g_vkCommandBuffer, VK_TRUE);
|
|
||||||
vkCmdSetDepthWriteEnable(g_vkCommandBuffer, VK_TRUE);
|
|
||||||
vkCmdSetDepthCompareOp(g_vkCommandBuffer, VK_COMPARE_OP_LESS);
|
|
||||||
vkCmdSetStencilTestEnable(g_vkCommandBuffer, VK_FALSE);
|
|
||||||
|
|
||||||
_vkCmdSetRasterizationSamplesEXT(g_vkCommandBuffer, VK_SAMPLE_COUNT_1_BIT);
|
|
||||||
VkSampleMask sampleMask = 0xFFFFFFFF;
|
|
||||||
_vkCmdSetSampleMaskEXT(g_vkCommandBuffer, VK_SAMPLE_COUNT_1_BIT, &sampleMask);
|
|
||||||
_vkCmdSetAlphaToCoverageEnableEXT(g_vkCommandBuffer, VK_FALSE);
|
|
||||||
|
|
||||||
VkViewport viewport = {0, 0, (float)g_nWindowWidth, (float)g_nWindowHeight, 0.0f, 1.0f};
|
|
||||||
VkRect2D scissor = {{0, 0}, {g_nWindowWidth, g_nWindowHeight}};
|
|
||||||
vkCmdSetViewportWithCount(g_vkCommandBuffer, 1, &viewport);
|
|
||||||
vkCmdSetScissorWithCount(g_vkCommandBuffer, 1, &scissor);
|
|
||||||
|
|
||||||
vkCmdSetPrimitiveTopology(g_vkCommandBuffer, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
|
|
||||||
vkCmdSetPrimitiveRestartEnable(g_vkCommandBuffer, VK_FALSE);
|
|
||||||
|
|
||||||
VkVertexInputBindingDescription2EXT binding = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT,
|
|
||||||
.binding = 0,
|
|
||||||
.stride = 20,
|
|
||||||
.inputRate = VK_VERTEX_INPUT_RATE_VERTEX,
|
|
||||||
.divisor = 1,
|
|
||||||
};
|
|
||||||
VkVertexInputAttributeDescription2EXT attributes[2] = {
|
|
||||||
{
|
|
||||||
VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT,
|
|
||||||
NULL,
|
|
||||||
0, 0,
|
|
||||||
VK_FORMAT_R32G32B32_SFLOAT,
|
|
||||||
0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT,
|
|
||||||
NULL,
|
|
||||||
1, 0,
|
|
||||||
VK_FORMAT_R32G32_SFLOAT,
|
|
||||||
12
|
|
||||||
}
|
|
||||||
};
|
|
||||||
_vkCmdSetVertexInputEXT(g_vkCommandBuffer, 1, &binding, 2, attributes);
|
|
||||||
|
|
||||||
VkBool32 blendEnable = VK_FALSE;
|
|
||||||
VkColorBlendEquationEXT blendEquation = {
|
|
||||||
VK_BLEND_FACTOR_SRC_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, VK_BLEND_OP_ADD,
|
|
||||||
VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD
|
|
||||||
};
|
|
||||||
VkColorComponentFlags writeMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
|
||||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
|
||||||
|
|
||||||
_vkCmdSetColorBlendEnableEXT(g_vkCommandBuffer, 0, 1, &blendEnable);
|
|
||||||
_vkCmdSetColorBlendEquationEXT(g_vkCommandBuffer, 0, 1, &blendEquation);
|
|
||||||
_vkCmdSetColorWriteMaskEXT(g_vkCommandBuffer, 0, 1, &writeMask);
|
|
||||||
|
|
||||||
vkCmdBindPipeline(g_vkCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_brushPipeline.m_pipeline);
|
|
||||||
vkCmdBindDescriptorSets(g_vkCommandBuffer,VK_PIPELINE_BIND_POINT_GRAPHICS, g_brushPipeline.m_layout, 0, 1, &g_brushDescriptorSet, 0, NULL);
|
|
||||||
for (auto &mesh: g_drawnBrushes)
|
|
||||||
{
|
|
||||||
VkDeviceSize offset = 0;
|
|
||||||
uint32_t textureID = mesh.m_material.albedo;
|
|
||||||
vkCmdPushConstants(g_vkCommandBuffer, g_brushPipeline.m_layout, VK_SHADER_STAGE_ALL, 0, 4, &textureID);
|
|
||||||
vkCmdBindVertexBuffers(g_vkCommandBuffer, 0, 1, &mesh.m_pVertexBuffer->m_buffer.m_buffer, &offset);
|
|
||||||
if (mesh.m_pIndexBuffer)
|
|
||||||
{
|
|
||||||
vkCmdBindIndexBuffer(
|
|
||||||
g_vkCommandBuffer,
|
|
||||||
mesh.m_pIndexBuffer->m_buffer.m_buffer,
|
|
||||||
0,
|
|
||||||
VK_INDEX_TYPE_UINT32
|
|
||||||
);
|
|
||||||
vkCmdDrawIndexed(g_vkCommandBuffer, mesh.m_pIndexBuffer->m_buffer.m_nSize/4, 1, 0, 0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vkCmdDraw(g_vkCommandBuffer, mesh.m_pVertexBuffer->m_buffer.m_nSize/12,1,0,0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vkCmdEndRendering(g_vkCommandBuffer);
|
|
||||||
|
|
||||||
barrier = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
|
||||||
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
|
||||||
.dstAccessMask = 0,
|
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
|
||||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
|
||||||
.image = g_swapchainImage,
|
|
||||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
|
||||||
};
|
|
||||||
|
|
||||||
vkCmdPipelineBarrier(g_vkCommandBuffer,
|
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
|
||||||
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
|
||||||
0, 0, NULL, 0, NULL, 1, &barrier);
|
|
||||||
g_drawnBrushes = CUtlVector<CBrush>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IBrush *IBrushRenderer::CreateMesh()
|
|
||||||
{
|
|
||||||
CBrush *mesh = new CBrush;
|
|
||||||
return mesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IBrushRenderer::Destroy( IBrush *pModel )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -7,3 +7,4 @@ VK_DEVICE_FUNCTION(vkCmdSetViewportWithCount);
|
|||||||
VK_DEVICE_FUNCTION(vkCmdSetColorBlendEnableEXT);
|
VK_DEVICE_FUNCTION(vkCmdSetColorBlendEnableEXT);
|
||||||
VK_DEVICE_FUNCTION(vkCmdSetColorBlendEquationEXT);
|
VK_DEVICE_FUNCTION(vkCmdSetColorBlendEquationEXT);
|
||||||
VK_DEVICE_FUNCTION(vkCmdSetColorWriteMaskEXT);
|
VK_DEVICE_FUNCTION(vkCmdSetColorWriteMaskEXT);
|
||||||
|
VK_DEVICE_FUNCTION(vkCmdSetLogicOpEXT);
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ extern VkCommandPool g_vkCommandPool;
|
|||||||
extern VkCommandBuffer g_vkCommandBuffer;
|
extern VkCommandBuffer g_vkCommandBuffer;
|
||||||
extern VkImageView g_swapchainImageView;
|
extern VkImageView g_swapchainImageView;
|
||||||
extern VkImage g_swapchainImage;
|
extern VkImage g_swapchainImage;
|
||||||
|
extern VkFormat g_swapchainFormat;
|
||||||
|
|
||||||
extern bool g_bConfigNotify;
|
extern bool g_bConfigNotify;
|
||||||
extern uint32_t g_nWindowWidth;
|
extern uint32_t g_nWindowWidth;
|
||||||
@@ -78,5 +79,7 @@ struct CameraProjection {
|
|||||||
extern vk_buffer_t g_cameraProperties;
|
extern vk_buffer_t g_cameraProperties;
|
||||||
extern CameraProjection *g_cameraDataMap;
|
extern CameraProjection *g_cameraDataMap;
|
||||||
|
|
||||||
extern vk_image2d_t g_meshdepth;
|
extern vk_image2d_t g_meshDepth;
|
||||||
extern vk_image2d_t g_meshcolor;
|
extern vk_image2d_t g_meshDepthMSAA;
|
||||||
|
extern vk_image2d_t g_meshColor;
|
||||||
|
extern vk_image2d_t g_meshColorMSAA;
|
||||||
|
|||||||
@@ -107,7 +107,9 @@ void IMeshRenderer::Init()
|
|||||||
bindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
bindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
bindings[1].descriptorCount = 1024;
|
bindings[1].descriptorCount = 1024;
|
||||||
g_meshPipeline.Create(shaders, bindings, 76);
|
CUtlVector<VkFormat> formats(1);
|
||||||
|
formats[0] = g_meshColor.m_format;
|
||||||
|
g_meshPipeline.Create(shaders, bindings, 76, formats);
|
||||||
shaders[1].Destroy();
|
shaders[1].Destroy();
|
||||||
shaders[0].Destroy();
|
shaders[0].Destroy();
|
||||||
|
|
||||||
@@ -157,6 +159,31 @@ void IMeshRenderer::Init()
|
|||||||
vkCreateSampler(g_vkDevice, &samplerInfo, nullptr, &g_meshSampler);
|
vkCreateSampler(g_vkDevice, &samplerInfo, nullptr, &g_meshSampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IMeshRenderer_PrepassNoMSAA()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void IMeshRenderer_Prepass()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void IMeshRenderer_EdgeDetection()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void IMeshRenderer_Light()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void IMeshRenderer_Combine()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
void IMeshRenderer::Frame( float fDelta )
|
void IMeshRenderer::Frame( float fDelta )
|
||||||
{
|
{
|
||||||
CUtlVector<VkWriteDescriptorSet> writes(2);
|
CUtlVector<VkWriteDescriptorSet> writes(2);
|
||||||
@@ -183,7 +210,7 @@ void IMeshRenderer::Frame( float fDelta )
|
|||||||
{
|
{
|
||||||
CTexture *texture = (CTexture*)t;
|
CTexture *texture = (CTexture*)t;
|
||||||
VkDescriptorImageInfo image = {};
|
VkDescriptorImageInfo image = {};
|
||||||
image.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
image.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
image.imageView = texture->image.m_imageView;
|
image.imageView = texture->image.m_imageView;
|
||||||
image.sampler = g_meshSampler;
|
image.sampler = g_meshSampler;
|
||||||
textures.AppendTail(image);
|
textures.AppendTail(image);
|
||||||
@@ -196,33 +223,70 @@ void IMeshRenderer::Frame( float fDelta )
|
|||||||
vkUpdateDescriptorSets(g_vkDevice, writes.GetSize(), writes.GetData(), 0, NULL);
|
vkUpdateDescriptorSets(g_vkDevice, writes.GetSize(), writes.GetData(), 0, NULL);
|
||||||
|
|
||||||
|
|
||||||
VkImageMemoryBarrier barrier = {
|
VkImageMemoryBarrier barriers[4] = {
|
||||||
|
{
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
.srcAccessMask = 0,
|
.srcAccessMask = 0,
|
||||||
.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
.image = g_swapchainImage,
|
.image = g_meshColor.m_image,
|
||||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
|
.srcAccessMask = 0,
|
||||||
|
.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
|
.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
|
.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
|
.image = g_meshColorMSAA.m_image,
|
||||||
|
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
|
.srcAccessMask = 0,
|
||||||
|
.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
|
.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
|
.newLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
||||||
|
.image = g_meshDepth.m_image,
|
||||||
|
.subresourceRange = {VK_IMAGE_ASPECT_DEPTH_BIT, 0, 1, 0, 1}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
|
.srcAccessMask = 0,
|
||||||
|
.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
|
.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
|
.newLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
||||||
|
.image = g_meshDepthMSAA.m_image,
|
||||||
|
.subresourceRange = {VK_IMAGE_ASPECT_DEPTH_BIT, 0, 1, 0, 1}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
vkCmdPipelineBarrier(g_vkCommandBuffer,
|
vkCmdPipelineBarrier(g_vkCommandBuffer,
|
||||||
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||||
0, 0, NULL, 0, NULL, 1, &barrier);
|
0, 0, NULL, 0, NULL, 4, barriers);
|
||||||
|
|
||||||
VkRenderingAttachmentInfo colorAttachment = {
|
VkRenderingAttachmentInfo colorAttachment = {
|
||||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||||
.imageView = g_swapchainImageView,
|
.imageView = g_meshColorMSAA.m_imageView,
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
|
.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT,
|
||||||
|
.resolveImageView = g_meshColor.m_imageView,
|
||||||
|
.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
|
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
|
.clearValue = {.color = {0.0f, 0.0f, 0.0f, 1.0f}},
|
||||||
};
|
};
|
||||||
VkRenderingAttachmentInfo depthAttachment = {
|
VkRenderingAttachmentInfo depthAttachment = {
|
||||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||||
.imageView = g_meshdepth.m_imageView,
|
.imageView = g_meshDepthMSAA.m_imageView,
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
||||||
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
|
.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT,
|
||||||
|
.resolveImageView = g_meshDepth.m_imageView,
|
||||||
|
.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
||||||
|
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
|
.clearValue = {.depthStencil = {.depth = 1}},
|
||||||
};
|
};
|
||||||
|
|
||||||
VkRenderingInfo renderInfo = {
|
VkRenderingInfo renderInfo = {
|
||||||
@@ -246,9 +310,9 @@ void IMeshRenderer::Frame( float fDelta )
|
|||||||
vkCmdSetDepthCompareOp(g_vkCommandBuffer, VK_COMPARE_OP_LESS);
|
vkCmdSetDepthCompareOp(g_vkCommandBuffer, VK_COMPARE_OP_LESS);
|
||||||
vkCmdSetStencilTestEnable(g_vkCommandBuffer, VK_FALSE);
|
vkCmdSetStencilTestEnable(g_vkCommandBuffer, VK_FALSE);
|
||||||
|
|
||||||
_vkCmdSetRasterizationSamplesEXT(g_vkCommandBuffer, VK_SAMPLE_COUNT_1_BIT);
|
_vkCmdSetRasterizationSamplesEXT(g_vkCommandBuffer, VK_SAMPLE_COUNT_4_BIT);
|
||||||
VkSampleMask sampleMask = 0xFFFFFFFF;
|
VkSampleMask sampleMask = 0xFFFFFFFF;
|
||||||
_vkCmdSetSampleMaskEXT(g_vkCommandBuffer, VK_SAMPLE_COUNT_1_BIT, &sampleMask);
|
_vkCmdSetSampleMaskEXT(g_vkCommandBuffer, VK_SAMPLE_COUNT_4_BIT, &sampleMask);
|
||||||
_vkCmdSetAlphaToCoverageEnableEXT(g_vkCommandBuffer, VK_FALSE);
|
_vkCmdSetAlphaToCoverageEnableEXT(g_vkCommandBuffer, VK_FALSE);
|
||||||
|
|
||||||
VkViewport viewport = {0, 0, (float)g_nWindowWidth, (float)g_nWindowHeight, 0.0f, 1.0f};
|
VkViewport viewport = {0, 0, (float)g_nWindowWidth, (float)g_nWindowHeight, 0.0f, 1.0f};
|
||||||
@@ -301,8 +365,8 @@ void IMeshRenderer::Frame( float fDelta )
|
|||||||
for (auto &mesh: g_drawnMeshes)
|
for (auto &mesh: g_drawnMeshes)
|
||||||
{
|
{
|
||||||
VkDeviceSize offset = 0;
|
VkDeviceSize offset = 0;
|
||||||
uint32_t textureID = mesh.m_material.albedo;
|
uint32_t textureID = 0;
|
||||||
vkCmdPushConstants(g_vkCommandBuffer, g_meshPipeline.m_layout, VK_SHADER_STAGE_ALL, 0, 64, mesh.m_matrix);
|
vkCmdPushConstants(g_vkCommandBuffer, g_meshPipeline.m_layout, VK_SHADER_STAGE_ALL, 0, 64, &mesh.m_matrix);
|
||||||
vkCmdPushConstants(g_vkCommandBuffer, g_meshPipeline.m_layout, VK_SHADER_STAGE_ALL, 64, 4, &textureID);
|
vkCmdPushConstants(g_vkCommandBuffer, g_meshPipeline.m_layout, VK_SHADER_STAGE_ALL, 64, 4, &textureID);
|
||||||
vkCmdBindVertexBuffers(g_vkCommandBuffer, 0, 1, &mesh.m_pVertexBuffer->m_buffer.m_buffer, &offset);
|
vkCmdBindVertexBuffers(g_vkCommandBuffer, 0, 1, &mesh.m_pVertexBuffer->m_buffer.m_buffer, &offset);
|
||||||
if (mesh.m_pIndexBuffer)
|
if (mesh.m_pIndexBuffer)
|
||||||
@@ -322,13 +386,13 @@ void IMeshRenderer::Frame( float fDelta )
|
|||||||
}
|
}
|
||||||
vkCmdEndRendering(g_vkCommandBuffer);
|
vkCmdEndRendering(g_vkCommandBuffer);
|
||||||
|
|
||||||
barrier = {
|
VkImageMemoryBarrier barrier = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
.dstAccessMask = 0,
|
.dstAccessMask = 0,
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
||||||
.image = g_swapchainImage,
|
.image = g_meshColor.m_image,
|
||||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -336,6 +400,23 @@ void IMeshRenderer::Frame( float fDelta )
|
|||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||||
0, 0, NULL, 0, NULL, 1, &barrier);
|
0, 0, NULL, 0, NULL, 1, &barrier);
|
||||||
|
|
||||||
|
barrier = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
|
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
|
.dstAccessMask = 0,
|
||||||
|
.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
|
.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
||||||
|
.image = g_meshColor.m_image,
|
||||||
|
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
||||||
|
};
|
||||||
|
|
||||||
|
vkCmdPipelineBarrier(g_vkCommandBuffer,
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
|
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||||
|
0, 0, NULL, 0, NULL, 1, &barrier);
|
||||||
|
|
||||||
|
|
||||||
g_drawnMeshes = CUtlVector<CMesh>();
|
g_drawnMeshes = CUtlVector<CMesh>();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -347,7 +428,7 @@ IMesh *IMeshRenderer::CreateMesh()
|
|||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMeshRenderer::Destroy( IBrush *pModel )
|
void IMeshRenderer::Destroy( IMesh *pModel )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ CameraProjection *g_cameraDataMap;
|
|||||||
IMaterial *g_pDefaultMaterial;
|
IMaterial *g_pDefaultMaterial;
|
||||||
IMaterial *g_pCurrentMaterial;
|
IMaterial *g_pCurrentMaterial;
|
||||||
|
|
||||||
vk_image2d_t g_meshdepth;
|
vk_image2d_t g_meshDepth;
|
||||||
vk_image2d_t g_meshcolor;
|
vk_image2d_t g_meshDepthMSAA;
|
||||||
|
vk_image2d_t g_meshColor;
|
||||||
|
vk_image2d_t g_meshColorMSAA;
|
||||||
|
|
||||||
void IVulkan::Init()
|
void IVulkan::Init()
|
||||||
{
|
{
|
||||||
@@ -56,10 +58,11 @@ void IVulkan::Init()
|
|||||||
g_cameraProperties.Create(sizeof(CameraProjection), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
|
g_cameraProperties.Create(sizeof(CameraProjection), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
|
||||||
g_cameraDataMap = (CameraProjection*)g_cameraProperties.Map(0, 64);
|
g_cameraDataMap = (CameraProjection*)g_cameraProperties.Map(0, 64);
|
||||||
|
|
||||||
g_meshdepth.Create(1280, 720, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
|
g_meshDepth.Create(1280, 720, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_SAMPLE_COUNT_1_BIT);
|
||||||
g_meshcolor.Create(1280, 720, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
|
g_meshDepthMSAA.Create(1280, 720, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
||||||
|
g_meshColor.Create(1280, 720, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_SAMPLE_COUNT_1_BIT);
|
||||||
|
g_meshColorMSAA.Create(1280, 720, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
||||||
|
|
||||||
IBrushRenderer::Init();
|
|
||||||
IMeshRenderer::Init();
|
IMeshRenderer::Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,11 +76,17 @@ void IVulkan::Frame()
|
|||||||
|
|
||||||
if (g_bConfigNotify)
|
if (g_bConfigNotify)
|
||||||
{
|
{
|
||||||
g_meshdepth.Destroy();
|
g_meshDepth.Destroy();
|
||||||
g_meshdepth.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
|
g_meshDepthMSAA.Destroy();
|
||||||
|
g_meshColor.Destroy();
|
||||||
|
g_meshColorMSAA.Destroy();
|
||||||
|
|
||||||
|
g_meshDepth.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_SAMPLE_COUNT_1_BIT);
|
||||||
|
g_meshDepthMSAA.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_1_BIT);
|
||||||
|
g_meshColor.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_SAMPLE_COUNT_1_BIT);
|
||||||
|
g_meshColorMSAA.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, VK_SAMPLE_COUNT_4_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
IBrushRenderer::Frame(0);
|
|
||||||
IMeshRenderer::Frame(0);
|
IMeshRenderer::Frame(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -119,7 +128,8 @@ void vk_shader_t::Destroy( void )
|
|||||||
void vk_tripipeline_t::Create(
|
void vk_tripipeline_t::Create(
|
||||||
CUtlVector<vk_shader_t> &shaders,
|
CUtlVector<vk_shader_t> &shaders,
|
||||||
CUtlVector<VkDescriptorSetLayoutBinding> &bindings,
|
CUtlVector<VkDescriptorSetLayoutBinding> &bindings,
|
||||||
uint32_t pushConstantSize
|
uint32_t pushConstantSize,
|
||||||
|
CUtlVector<VkFormat> formats
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VkPushConstantRange pushConstantRange = {};
|
VkPushConstantRange pushConstantRange = {};
|
||||||
@@ -202,8 +212,8 @@ void vk_tripipeline_t::Create(
|
|||||||
VkPipelineRenderingCreateInfo prci = {
|
VkPipelineRenderingCreateInfo prci = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
|
||||||
.pNext = NULL,
|
.pNext = NULL,
|
||||||
.colorAttachmentCount = 1,
|
.colorAttachmentCount = (uint32_t)formats.GetSize(),
|
||||||
.pColorAttachmentFormats = (VkFormat[]){ VK_FORMAT_B8G8R8A8_UNORM }, // <-- replace with your actual format
|
.pColorAttachmentFormats = formats.GetData(),
|
||||||
.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT,
|
.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -272,7 +282,7 @@ void vk_buffer_t::CopyTo(struct vk_buffer_t *buffer)
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void vk_image2d_t::Create(size_t x, size_t y, VkFormat format, VkImageUsageFlags usage)
|
void vk_image2d_t::Create(size_t x, size_t y, VkFormat format, VkImageUsageFlags usage, VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT)
|
||||||
{
|
{
|
||||||
VkImageCreateInfo imageInfo={};
|
VkImageCreateInfo imageInfo={};
|
||||||
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||||
@@ -286,7 +296,7 @@ void vk_image2d_t::Create(size_t x, size_t y, VkFormat format, VkImageUsageFlags
|
|||||||
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||||
imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
imageInfo.format=format;
|
imageInfo.format=format;
|
||||||
imageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
imageInfo.samples = samples;
|
||||||
|
|
||||||
VmaAllocationCreateInfo alloc = {};
|
VmaAllocationCreateInfo alloc = {};
|
||||||
alloc.usage=VMA_MEMORY_USAGE_AUTO;
|
alloc.usage=VMA_MEMORY_USAGE_AUTO;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "vulkan/vulkan.h"
|
#include "vulkan/vulkan.h"
|
||||||
#include "SDL3/SDL.h"
|
#include "SDL3/SDL.h"
|
||||||
|
#include "vulkan/vulkan_core.h"
|
||||||
#define SDL_MAIN_HANDLED
|
#define SDL_MAIN_HANDLED
|
||||||
#include "SDL3/SDL_main.h"
|
#include "SDL3/SDL_main.h"
|
||||||
#include "SDL3/SDL_vulkan.h"
|
#include "SDL3/SDL_vulkan.h"
|
||||||
@@ -45,17 +46,18 @@ CUtlVector<VkImage> g_swapchainImages;
|
|||||||
CUtlVector<VkImageView> g_swapchainImageViews;
|
CUtlVector<VkImageView> g_swapchainImageViews;
|
||||||
VkImageView g_swapchainImageView;
|
VkImageView g_swapchainImageView;
|
||||||
VkImage g_swapchainImage;
|
VkImage g_swapchainImage;
|
||||||
|
VkFormat g_swapchainFormat;
|
||||||
|
|
||||||
uint32_t g_nNumSwapchainImages = 0;
|
uint32_t g_nNumSwapchainImages = 0;
|
||||||
|
|
||||||
#define VK_DEVICE_FUNCTION(name) PFN_##name _##name
|
|
||||||
#include "vk_external_functions.cpp"
|
|
||||||
#undef VK_DEVICE_FUNCTION
|
|
||||||
|
|
||||||
char g_bConfigNotify = 0;
|
char g_bConfigNotify = 0;
|
||||||
uint32_t g_nWindowWidth = 1280;
|
uint32_t g_nWindowWidth = 1280;
|
||||||
uint32_t g_nWindowHeight = 720;
|
uint32_t g_nWindowHeight = 720;
|
||||||
|
|
||||||
|
#define VK_DEVICE_FUNCTION(name) PFN_##name _##name
|
||||||
|
#include "vk_external_functions.cpp"
|
||||||
|
#undef VK_DEVICE_FUNCTION
|
||||||
|
|
||||||
void IVideo_SwapchainInit()
|
void IVideo_SwapchainInit()
|
||||||
{
|
{
|
||||||
@@ -131,6 +133,7 @@ void IVideo_SwapchainInit()
|
|||||||
|
|
||||||
vkCreateImageView(g_vkDevice, &createInfo, NULL, &g_swapchainImageViews[i]);
|
vkCreateImageView(g_vkDevice, &createInfo, NULL, &g_swapchainImageViews[i]);
|
||||||
}
|
}
|
||||||
|
g_swapchainFormat = selectedFormat.format;
|
||||||
|
|
||||||
|
|
||||||
/* command buffers */
|
/* command buffers */
|
||||||
@@ -283,6 +286,7 @@ void IVideo::Init()
|
|||||||
VkPhysicalDeviceVulkan13Features pdv13f = {
|
VkPhysicalDeviceVulkan13Features pdv13f = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
|
||||||
.pNext = &pdeds2fe,
|
.pNext = &pdeds2fe,
|
||||||
|
.synchronization2 = VK_TRUE,
|
||||||
.dynamicRendering = VK_TRUE,
|
.dynamicRendering = VK_TRUE,
|
||||||
};
|
};
|
||||||
VkPhysicalDeviceVulkan12Features pdv12f = {
|
VkPhysicalDeviceVulkan12Features pdv12f = {
|
||||||
@@ -421,4 +425,5 @@ void IVideo::Frame( float fDelta )
|
|||||||
|
|
||||||
g_bConfigNotify = 0;
|
g_bConfigNotify = 0;
|
||||||
s_frameID=(s_frameID+1)%g_nNumSwapchainImages;
|
s_frameID=(s_frameID+1)%g_nNumSwapchainImages;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"classname" "worldspawn"
|
"classname" "worldspawn"
|
||||||
|
"origin" "0 0 0"
|
||||||
{
|
{
|
||||||
(10.000000 2.000001 -2.000000) (9.999999 6.000001 -2.000000) (9.999999 6.000001 -4.000000) (6.483328 1.451694) (6.483328 0.190320) (7.114015 0.190320) BRICK0
|
(10.000000 2.000001 -2.000000) (9.999999 6.000001 -2.000000) (9.999999 6.000001 -4.000000) (6.483328 1.451694) (6.483328 0.190320) (7.114015 0.190320) BRICK0
|
||||||
(10.000000 2.000001 -2.000000) (9.999999 6.000001 -4.000000) (10.000000 2.000001 -4.000000) (6.483328 1.451694) (7.114015 0.190320) (7.114015 1.451694) BRICK0
|
(10.000000 2.000001 -2.000000) (9.999999 6.000001 -4.000000) (10.000000 2.000001 -4.000000) (6.483328 1.451694) (7.114015 0.190320) (7.114015 1.451694) BRICK0
|
||||||
@@ -98,5 +99,6 @@
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
"classname" "light"
|
"classname" "light"
|
||||||
|
"origin" "10 0 4"
|
||||||
"intensity" "4.0"
|
"intensity" "4.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class CBasePlayer: public CBaseEntity
|
|||||||
public:
|
public:
|
||||||
virtual void Precache ( void ) override;
|
virtual void Precache ( void ) override;
|
||||||
virtual void Spawn( void ) override;
|
virtual void Spawn( void ) override;
|
||||||
|
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||||
virtual void Destroy( void ) override;
|
virtual void Destroy( void ) override;
|
||||||
virtual void Think( float fDelta ) override;
|
virtual void Think( float fDelta ) override;
|
||||||
};
|
};
|
||||||
@@ -19,6 +20,10 @@ void CBasePlayer::Spawn()
|
|||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
void CBasePlayer::ReadParameter( const char *szName, const char *szValue )
|
||||||
|
{
|
||||||
|
CBaseEntity::ReadParameter(szName, szValue);
|
||||||
|
}
|
||||||
|
|
||||||
void CBasePlayer::Destroy()
|
void CBasePlayer::Destroy()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,16 +8,11 @@
|
|||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
class C_BaseEntity;
|
class C_BaseEntity;
|
||||||
|
|
||||||
struct Triangle_t
|
//-----------------------------------------------------------------------------
|
||||||
{
|
// Base server entity class.
|
||||||
float location[9];
|
// It is updated every 1/tickrate (64) of a second. Does not require special
|
||||||
float uv[6];
|
// classes to exist.
|
||||||
float normal[9];
|
//-----------------------------------------------------------------------------
|
||||||
uint32_t texture;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* server entities */
|
|
||||||
|
|
||||||
class CBaseEntity
|
class CBaseEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -25,10 +20,18 @@ public:
|
|||||||
virtual void Precache() = 0;
|
virtual void Precache() = 0;
|
||||||
virtual void Spawn( void ) = 0;
|
virtual void Spawn( void ) = 0;
|
||||||
virtual void Destroy( void ) = 0;
|
virtual void Destroy( void ) = 0;
|
||||||
|
virtual void ReadParameter( const char *szName, const char *szValue );
|
||||||
virtual void Think( float fDelta ) = 0;
|
virtual void Think( float fDelta ) = 0;
|
||||||
|
void SetPosition( vec3 position );
|
||||||
|
void SetRotationEuler( vec3 euler );
|
||||||
|
void SetRotationQuat( vec4 quaternion );
|
||||||
|
void SetRotationMatrix( mat3 matrix );
|
||||||
|
void SetScale( vec3 scale );
|
||||||
|
|
||||||
C_BaseEntity *pClientEntity;
|
C_BaseEntity *pClientEntity;
|
||||||
mat4 m_matrix;
|
mat3 m_matrix;
|
||||||
|
vec3 m_position;
|
||||||
|
vec3 m_scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -55,9 +58,12 @@ CBaseEntity *__entity_alloc_##name() \
|
|||||||
}; \
|
}; \
|
||||||
CEntityRegistry __entity_##name##_registry(#name, #class, __entity_alloc_##name); \
|
CEntityRegistry __entity_##name##_registry(#name, #class, __entity_alloc_##name); \
|
||||||
|
|
||||||
/* client entities */
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Base client entity class.
|
||||||
|
// It recieves pure server data, which has to be interpolated by the client to
|
||||||
|
// get smoother image.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
class C_BaseEntity
|
class C_BaseEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -66,7 +72,6 @@ public:
|
|||||||
virtual void Precache() = 0;
|
virtual void Precache() = 0;
|
||||||
virtual void Spawn( void ) = 0;
|
virtual void Spawn( void ) = 0;
|
||||||
virtual void Destroy( void ) = 0;
|
virtual void Destroy( void ) = 0;
|
||||||
/* happens every frame instead of tick */
|
|
||||||
virtual void Think( float fDelta ) = 0;
|
virtual void Think( float fDelta ) = 0;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
@@ -77,6 +82,10 @@ public:
|
|||||||
C_EntityRegistry( const char *pName, ClientEntityRegistryFn pfn );
|
C_EntityRegistry( const char *pName, ClientEntityRegistryFn pfn );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Server-Client sync for entities. When new server entity is created, client
|
||||||
|
// entity gets created as well.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
#define LINK_CLIENT_ENTITY(client, server) \
|
#define LINK_CLIENT_ENTITY(client, server) \
|
||||||
C_BaseEntity *__c_entity_alloc_##server() \
|
C_BaseEntity *__c_entity_alloc_##server() \
|
||||||
{ \
|
{ \
|
||||||
|
|||||||
@@ -6,11 +6,29 @@
|
|||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Basic triangle structure which is used in brush entities.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
struct Triangle_t
|
||||||
|
{
|
||||||
|
float location[9];
|
||||||
|
float uv[6];
|
||||||
|
float normal[9];
|
||||||
|
uint32_t texture;
|
||||||
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Basic brush entity which has its own geometry defined.
|
||||||
|
// They have constant position, shape, and rotation, so it makes them
|
||||||
|
// non-interactable with the game world in terms of ability to modify it at
|
||||||
|
// runtime. Collisions are precise.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
class CBrushEntity: public CBaseEntity
|
class CBrushEntity: public CBaseEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Precache ( void ) override;
|
virtual void Precache ( void ) override;
|
||||||
virtual void Spawn( void ) override;
|
virtual void Spawn( void ) override;
|
||||||
|
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||||
virtual void Destroy( void ) override;
|
virtual void Destroy( void ) override;
|
||||||
virtual void Think( float fDelta ) override;
|
virtual void Think( float fDelta ) override;
|
||||||
|
|
||||||
@@ -19,6 +37,9 @@ public:
|
|||||||
RigidBodyHandle *m_body;
|
RigidBodyHandle *m_body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Client rendering for brush entitites.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
class C_BrushEntity: public C_BaseEntity
|
class C_BrushEntity: public C_BaseEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -29,7 +50,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
IVertexBuffer *vertexBuffer;
|
IVertexBuffer *vertexBuffer;
|
||||||
IIndexBuffer *indexBuffer;
|
IIndexBuffer *indexBuffer;
|
||||||
IBrush *mesh;
|
IMesh *mesh;
|
||||||
IMaterial material;
|
IMaterial material;
|
||||||
ITexture *pAlbedo;
|
ITexture *pAlbedo;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
|
|
||||||
enum EFileOptions
|
enum EFileOptions
|
||||||
{
|
{
|
||||||
IFILE_READ,
|
IFILE_READ,
|
||||||
|
|||||||
@@ -79,28 +79,6 @@ public:
|
|||||||
static void SetMaterial( IMaterial *pMaterial );
|
static void SetMaterial( IMaterial *pMaterial );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Brush handler for the rendering
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
abstract_class IBrush
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void SetVertexBuffer( IVertexBuffer *pBuffer ) = 0;
|
|
||||||
virtual void SetIndexBuffer( IIndexBuffer *pBuffer ) = 0;
|
|
||||||
virtual void Draw() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface IBrushRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void Init();
|
|
||||||
static void Frame( float fDelta );
|
|
||||||
|
|
||||||
static IBrush *CreateMesh();
|
|
||||||
static void Destroy( IBrush *pModel );
|
|
||||||
};
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Mesh handler for the rendering
|
// Mesh handler for the rendering
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -125,7 +103,7 @@ public:
|
|||||||
static void Frame( float fDelta );
|
static void Frame( float fDelta );
|
||||||
|
|
||||||
static IMesh *CreateMesh();
|
static IMesh *CreateMesh();
|
||||||
static void Destroy( IBrush *pModel );
|
static void Destroy( IMesh *pModel );
|
||||||
};
|
};
|
||||||
|
|
||||||
abstract_class ITexture
|
abstract_class ITexture
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
#define V_putchar putchar
|
#define V_putchar putchar
|
||||||
#define V_fputchar fputchar
|
#define V_fputchar fputchar
|
||||||
#define V_scanf scanf
|
#define V_scanf scanf
|
||||||
|
#define V_sscanf sscanf
|
||||||
#define V_vscanf vscanf
|
#define V_vscanf vscanf
|
||||||
#define V_fscanf fscanf
|
#define V_fscanf fscanf
|
||||||
#define V_vfscanf vfscanf
|
#define V_vfscanf vfscanf
|
||||||
|
|||||||
1
public/tier1/ban_std.h
Normal file
1
public/tier1/ban_std.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#define std no_you_do_not_use_std
|
||||||
1
public/tier1/unban_std.h
Normal file
1
public/tier1/unban_std.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#undef std
|
||||||
@@ -24,7 +24,7 @@ public:
|
|||||||
CUtlBuffer( const CUtlResizableBuffer<T>& buffer );
|
CUtlBuffer( const CUtlResizableBuffer<T>& buffer );
|
||||||
|
|
||||||
size_t GetSize( void ) const;
|
size_t GetSize( void ) const;
|
||||||
void* GetMemory(void) const;
|
T* GetMemory(void) const;
|
||||||
|
|
||||||
operator T*( void ) const;
|
operator T*( void ) const;
|
||||||
T& operator []( const size_t nIndex );
|
T& operator []( const size_t nIndex );
|
||||||
@@ -89,7 +89,7 @@ size_t CUtlBuffer<T>::GetSize( void ) const
|
|||||||
// Gets memory address.
|
// Gets memory address.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void* CUtlBuffer<T>::GetMemory( void ) const
|
T* CUtlBuffer<T>::GetMemory( void ) const
|
||||||
{
|
{
|
||||||
return m_pData;
|
return m_pData;
|
||||||
}
|
}
|
||||||
@@ -110,10 +110,10 @@ template <typename T>
|
|||||||
T& CUtlBuffer<T>::operator []( const size_t nIndex )
|
T& CUtlBuffer<T>::operator []( const size_t nIndex )
|
||||||
{
|
{
|
||||||
if ( m_pData == 0)
|
if ( m_pData == 0)
|
||||||
Plat_FatalErrorFunc("Buffer was not initialized");
|
Plat_FatalErrorFunc("Buffer was not initialized\n");
|
||||||
|
|
||||||
if ( nIndex >= m_nSize )
|
if ( nIndex >= m_nSize )
|
||||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu", m_nSize/sizeof(T), nIndex);
|
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n", m_nSize/sizeof(T), nIndex);
|
||||||
|
|
||||||
return m_pData[nIndex];
|
return m_pData[nIndex];
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ template <typename T>
|
|||||||
T CUtlBuffer<T>::operator []( const size_t nIndex ) const
|
T CUtlBuffer<T>::operator []( const size_t nIndex ) const
|
||||||
{
|
{
|
||||||
if ( nIndex >= m_nSize )
|
if ( nIndex >= m_nSize )
|
||||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu",m_nSize, nIndex);
|
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n",m_nSize, nIndex);
|
||||||
return m_pData[nIndex];
|
return m_pData[nIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,10 +293,10 @@ template <typename T>
|
|||||||
T& CUtlResizableBuffer<T>::operator []( const size_t nIndex )
|
T& CUtlResizableBuffer<T>::operator []( const size_t nIndex )
|
||||||
{
|
{
|
||||||
if ( m_pData == 0)
|
if ( m_pData == 0)
|
||||||
Plat_FatalErrorFunc("Buffer was not initialized");
|
Plat_FatalErrorFunc("Buffer was not initialized\n");
|
||||||
|
|
||||||
if ( nIndex >= m_nSize )
|
if ( nIndex >= m_nSize )
|
||||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu",m_nSize, nIndex);
|
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n",m_nSize, nIndex);
|
||||||
|
|
||||||
return m_pData[nIndex];
|
return m_pData[nIndex];
|
||||||
}
|
}
|
||||||
@@ -308,7 +308,7 @@ template <typename T>
|
|||||||
T CUtlResizableBuffer<T>::operator []( const size_t nIndex ) const
|
T CUtlResizableBuffer<T>::operator []( const size_t nIndex ) const
|
||||||
{
|
{
|
||||||
if ( nIndex >= m_nSize )
|
if ( nIndex >= m_nSize )
|
||||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu",m_nSize, nIndex);
|
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n",m_nSize, nIndex);
|
||||||
return m_pData[nIndex];
|
return m_pData[nIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
public/tier1/utlinitlist.h
Normal file
19
public/tier1/utlinitlist.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef TIER1_UTL_INITIALIZER_LIST_H
|
||||||
|
#define TIER1_UTL_INITIALIZER_LIST_H
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// C++ only supports std::initializer_list. Because of that we are dependent
|
||||||
|
// on libc++. That's why I banned usage of the std.
|
||||||
|
//
|
||||||
|
// fuck C++ once
|
||||||
|
// fuck C++ twice
|
||||||
|
// fuck C++ thrice
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#include "unban_std.h"
|
||||||
|
|
||||||
|
#include "initializer_list"
|
||||||
|
template<typename T>
|
||||||
|
using CUtlInitializerList = std::initializer_list<T>;
|
||||||
|
|
||||||
|
#include "ban_std.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -6,7 +6,8 @@
|
|||||||
class CUtlString {
|
class CUtlString {
|
||||||
public:
|
public:
|
||||||
CUtlString( void );
|
CUtlString( void );
|
||||||
CUtlString( const char *psz, ... );
|
CUtlString( const char *psz, ... );
|
||||||
|
CUtlString( const CUtlString &sz );
|
||||||
|
|
||||||
void AppendTail( const char *psz );
|
void AppendTail( const char *psz );
|
||||||
void AppendHead( const char *psz );
|
void AppendHead( const char *psz );
|
||||||
@@ -19,6 +20,7 @@ public:
|
|||||||
char *GetString( void );
|
char *GetString( void );
|
||||||
size_t GetLenght( void );
|
size_t GetLenght( void );
|
||||||
operator char*( void );
|
operator char*( void );
|
||||||
|
CUtlString& operator=(const CUtlString &sz);
|
||||||
bool operator==(const char* psz);
|
bool operator==(const char* psz);
|
||||||
bool operator!=(const char* psz);
|
bool operator!=(const char* psz);
|
||||||
bool operator==(CUtlString& string);
|
bool operator==(CUtlString& string);
|
||||||
@@ -27,4 +29,4 @@ private:
|
|||||||
CUtlVector<char> m_data;
|
CUtlVector<char> m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include "tier1/utlbuffer.h"
|
#include "tier1/utlbuffer.h"
|
||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
|
#include "tier1/utlinitlist.h"
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Basic vector implementation. There isn't much in them.
|
// Basic vector implementation. There isn't much in them.
|
||||||
@@ -14,6 +15,9 @@ class CUtlVector
|
|||||||
public:
|
public:
|
||||||
CUtlVector( void );
|
CUtlVector( void );
|
||||||
CUtlVector( size_t nSize );
|
CUtlVector( size_t nSize );
|
||||||
|
CUtlVector( CUtlInitializerList<T> initalizerList );
|
||||||
|
CUtlVector( const CUtlVector &vector );
|
||||||
|
~CUtlVector();
|
||||||
|
|
||||||
void AppendHead( const T &data );
|
void AppendHead( const T &data );
|
||||||
void AppendHead( const T *pData, size_t n );
|
void AppendHead( const T *pData, size_t n );
|
||||||
@@ -33,6 +37,7 @@ public:
|
|||||||
|
|
||||||
T &operator[]( size_t nIndex );
|
T &operator[]( size_t nIndex );
|
||||||
T &operator[]( size_t nIndex ) const;
|
T &operator[]( size_t nIndex ) const;
|
||||||
|
CUtlVector<T> &operator=(const CUtlVector<T> &vec);
|
||||||
|
|
||||||
// Iterator stuff
|
// Iterator stuff
|
||||||
struct Iterator {
|
struct Iterator {
|
||||||
@@ -83,6 +88,29 @@ CUtlVector<T>::CUtlVector( size_t nSize )
|
|||||||
m_nSize = nSize;
|
m_nSize = nSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// Fancy constructor
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
template<typename T>
|
||||||
|
CUtlVector<T>::CUtlVector( CUtlInitializerList<T> initalizerList )
|
||||||
|
{
|
||||||
|
m_data.Resize(initalizerList.size());
|
||||||
|
m_nSize = m_data.GetSize();
|
||||||
|
V_memcpy(m_data.GetMemory(), initalizerList.begin(), m_data.GetSize()*sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
CUtlVector<T>::CUtlVector( const CUtlVector& vector )
|
||||||
|
{
|
||||||
|
m_data = vector.m_data;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
CUtlVector<T>::~CUtlVector()
|
||||||
|
{
|
||||||
|
for ( uint32_t i = 0; i < m_nSize; i++ )
|
||||||
|
m_data[i].~T();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void CUtlVector<T>::AppendHead( const T &data )
|
void CUtlVector<T>::AppendHead( const T &data )
|
||||||
{
|
{
|
||||||
@@ -159,6 +187,18 @@ void CUtlVector<T>::Reserve( size_t nSize )
|
|||||||
{
|
{
|
||||||
m_data.Resize(nSize);
|
m_data.Resize(nSize);
|
||||||
}
|
}
|
||||||
|
template<typename T>
|
||||||
|
CUtlVector<T> &CUtlVector<T>::operator=(const CUtlVector<T> &vec)
|
||||||
|
{
|
||||||
|
if (this != &vec)
|
||||||
|
{
|
||||||
|
m_nSize = vec.m_nSize;
|
||||||
|
m_data.Resize(m_nSize);
|
||||||
|
for ( uint32_t i = 0; i < m_nSize; i++ )
|
||||||
|
m_data[i] = vec.m_data[i];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T &CUtlVector<T>::operator[]( size_t nIndex )
|
T &CUtlVector<T>::operator[]( size_t nIndex )
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ struct vk_tripipeline_t
|
|||||||
void Create(
|
void Create(
|
||||||
CUtlVector<vk_shader_t> &shaders,
|
CUtlVector<vk_shader_t> &shaders,
|
||||||
CUtlVector<VkDescriptorSetLayoutBinding> &bindings,
|
CUtlVector<VkDescriptorSetLayoutBinding> &bindings,
|
||||||
uint32_t pushConstantsSize
|
uint32_t pushConstantsSize,
|
||||||
|
CUtlVector<VkFormat> formats
|
||||||
/* the rest of the stuff is set by the dynamic state */
|
/* the rest of the stuff is set by the dynamic state */
|
||||||
/* literally */
|
/* literally */
|
||||||
);
|
);
|
||||||
@@ -69,7 +70,7 @@ struct vk_buffer_t
|
|||||||
|
|
||||||
struct vk_image2d_t
|
struct vk_image2d_t
|
||||||
{
|
{
|
||||||
void Create(size_t x, size_t y, VkFormat format, VkImageUsageFlags usage);
|
void Create(size_t x, size_t y, VkFormat format, VkImageUsageFlags usage, VkSampleCountFlagBits samples);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
void CopyTo(struct vk_image2d_t *image);
|
void CopyTo(struct vk_image2d_t *image);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "sys/stat.h"
|
#include "sys/stat.h"
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
#include "signal.h"
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include "dlfcn.h"
|
#include "dlfcn.h"
|
||||||
#include "execinfo.h"
|
#include "execinfo.h"
|
||||||
@@ -20,6 +21,7 @@ PLATFORM_INTERFACE void Plat_FatalErrorFunc(const char* szFormat, ...)
|
|||||||
V_vprintf(szFormat, list);
|
V_vprintf(szFormat, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
raise(SIGTRAP);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ void ICommandLine::CreateCommandLine( int argc, char **argv )
|
|||||||
bool ICommandLine::CheckParam( char *psz )
|
bool ICommandLine::CheckParam( char *psz )
|
||||||
{
|
{
|
||||||
for (auto szParam: cl_params) {
|
for (auto szParam: cl_params) {
|
||||||
V_printf("%s\n",szParam);
|
if (!V_strcmp(szParam, psz))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -58,4 +61,4 @@ const char *ICommandLine::GetParam(int nIndex)
|
|||||||
return cl_params[nIndex];
|
return cl_params[nIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
static ICommandLine g_CommandLine;
|
static ICommandLine g_CommandLine;
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ CUtlString::CUtlString( const char *szFormat, ... )
|
|||||||
va_end(vlArgs);
|
va_end(vlArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUtlString::CUtlString( const CUtlString &sz )
|
||||||
|
{
|
||||||
|
m_data = sz.m_data;
|
||||||
|
};
|
||||||
|
|
||||||
void CUtlString::AppendTail( const char *psz )
|
void CUtlString::AppendTail( const char *psz )
|
||||||
{
|
{
|
||||||
m_data.AppendTail(psz,V_strlen(psz));
|
m_data.AppendTail(psz,V_strlen(psz));
|
||||||
@@ -65,7 +70,14 @@ CUtlString::operator char*( void )
|
|||||||
return GetString();
|
return GetString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUtlString::operator==(const char* psz)
|
CUtlString &CUtlString::operator=(const CUtlString &sz)
|
||||||
|
{
|
||||||
|
if (this != &sz)
|
||||||
|
m_data = sz.m_data;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CUtlString::operator==(const char *psz)
|
||||||
{
|
{
|
||||||
if (psz==0)
|
if (psz==0)
|
||||||
psz = "";
|
psz = "";
|
||||||
@@ -73,7 +85,7 @@ bool CUtlString::operator==(const char* psz)
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool CUtlString::operator!=(const char* psz)
|
bool CUtlString::operator!=(const char *psz)
|
||||||
{
|
{
|
||||||
if (psz==0)
|
if (psz==0)
|
||||||
psz = "";
|
psz = "";
|
||||||
@@ -82,13 +94,13 @@ bool CUtlString::operator!=(const char* psz)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUtlString::operator==(CUtlString& string)
|
bool CUtlString::operator==(CUtlString &string)
|
||||||
{
|
{
|
||||||
if (!V_strcmp(GetString(), string.GetString()))
|
if (!V_strcmp(GetString(), string.GetString()))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool CUtlString::operator!=(CUtlString& string)
|
bool CUtlString::operator!=(CUtlString &string)
|
||||||
{
|
{
|
||||||
if (!V_strcmp(GetString(), string.GetString()))
|
if (!V_strcmp(GetString(), string.GetString()))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user