Skip to content

Commit

Permalink
Main menu casual/competitive badge is no longer "crash the game" button
Browse files Browse the repository at this point in the history
  • Loading branch information
PazerOP committed May 21, 2019
1 parent 42081d8 commit ea05907
Show file tree
Hide file tree
Showing 25 changed files with 364 additions and 311 deletions.
2 changes: 1 addition & 1 deletion TF2VulkanUtil/include/TF2Vulkan/Util/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace Util

//#define TF2VULKAN_ENABLE_FUNCTION_LOGGING 1
#if defined(TF2VULKAN_ENABLE_FUNCTION_LOGGING)
#define LOG_FUNC_MSG(msg) ::Util::LogFunctionCallScope<TF2VULKAN_LOCAL_ENABLE_FUNCTION_LOGGING> EXPAND_CONCAT(_TF2Vulkan_LogFunctionCallScope_, __LINE__) (__FUNCSIG__, __FILE__, __LINE__, msg)
#define LOG_FUNC_MSG(msg) ::Util::LogFunctionCallScope<TF2VULKAN_LOCAL_ENABLE_FUNCTION_LOGGING> EXPAND_CONCAT(_TF2Vulkan_LogFunctionCallScope_, __COUNTER__) (__FUNCSIG__, __FILE__, __LINE__, msg)
#else
#define LOG_FUNC_MSG(msg) { ASSERT_MAIN_THREAD(); }
#endif
Expand Down
2 changes: 1 addition & 1 deletion TF2VulkanUtil/src/TF2Vulkan/Util/Macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void Util::EnsureConditionFailed(const char* condition, const char* fnSig, const

void Util::FunctionNotImplemented(const char* fnSig, const char* file, int line)
{
Warning("[TF2Vulkan] %s in %s:%i not implemented\n", fnSig, file, line);
Warning("[TF2Vulkan] NOT IMPLEMENTED: %s in %s:%i\n", fnSig, file, line);
}

static thread_local int s_LogFunctionCallIndentation = 0;
Expand Down
7 changes: 5 additions & 2 deletions shaderapivulkan/include/TF2Vulkan/VertexFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace TF2Vulkan
Meta_VertexShader = VERTEX_FORMAT_VERTEX_SHADER,
Meta_UseExactFormat = VERTEX_FORMAT_USE_EXACT_FORMAT,
Meta_Compressed = VERTEX_FORMAT_COMPRESSED,
Meta_Unknown = VERTEX_FORMAT_UNKNOWN,
};

union VertexFormat
Expand Down Expand Up @@ -60,6 +61,8 @@ namespace TF2Vulkan
void SetTexCoordSize(uint_fast8_t index, uint_fast8_t size);
VertexCompressionType_t GetCompressionType() const;

constexpr bool IsUnknownFormat() const { return m_Flags == VertexFormatFlags::Meta_Unknown; }

void SetCompressionEnabled(bool enabled);

struct ElementType final
Expand All @@ -82,8 +85,8 @@ namespace TF2Vulkan

struct Element
{
const ElementType* m_Type = nullptr;
uint_fast8_t m_Offset = 0;
const ElementType* m_Type;// = nullptr;
uint_fast8_t m_Offset;// = 0;
};

[[nodiscard]] uint_fast8_t GetVertexElements(Element* elements, uint_fast8_t maxElements, size_t* totalSize = nullptr) const;
Expand Down
12 changes: 7 additions & 5 deletions shaderapivulkan/shaderapivulkan.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
<ClInclude Include="src\TF2Vulkan\BufferPool.h" />
<ClInclude Include="src\TF2Vulkan\Exceptions.h" />
<ClInclude Include="src\TF2Vulkan\FormatConverter.h" />
<ClInclude Include="src\TF2Vulkan\IShaderTextureManager.h" />
<ClInclude Include="src\TF2Vulkan\IShaderAPI\IShaderAPI_MeshManager.h" />
<ClInclude Include="src\TF2Vulkan\IShaderAPI\IShaderAPI_TextureManager.h" />
<ClInclude Include="src\TF2Vulkan\PixScope.h" />
<ClInclude Include="include\TF2Vulkan\TextureData.h" />
<ClInclude Include="src\interface\internal\IStateManagerStatic.h" />
Expand All @@ -129,7 +130,7 @@
<ClInclude Include="src\TF2Vulkan\SamplerSettings.h" />
<ClInclude Include="src\interface\internal\IShaderDeviceMgrInternal.h" />
<ClInclude Include="src\TF2Vulkan\shaders\VulkanShaderManager.h" />
<ClInclude Include="src\TF2Vulkan\StateManagerDynamic.h" />
<ClInclude Include="src\TF2Vulkan\IShaderAPI\IShaderAPI_StateManagerDynamic.h" />
<ClInclude Include="src\TF2Vulkan\IStateManagerVulkan.h" />
<ClInclude Include="include\TF2Vulkan\VertexFormat.h" />
<ClInclude Include="src\TF2Vulkan\vk_mem_alloc.h" />
Expand Down Expand Up @@ -157,10 +158,11 @@
<ClCompile Include="src\TF2Vulkan\FormatInfo.cpp" />
<ClCompile Include="src\TF2Vulkan\GraphicsPipeline.cpp" />
<ClCompile Include="src\interface\internal\IVulkanQueue.cpp" />
<ClCompile Include="src\TF2Vulkan\IShaderTextureManager.cpp" />
<ClCompile Include="src\TF2Vulkan\IShaderAPI\IShaderAPI_MeshManager.cpp" />
<ClCompile Include="src\TF2Vulkan\IShaderAPI\IShaderAPI_TextureManager.cpp" />
<ClCompile Include="src\TF2Vulkan\MaterialSystemHardwareConfig.cpp" />
<ClCompile Include="src\TF2Vulkan\PixScope.cpp" />
<ClCompile Include="src\TF2Vulkan\ShaderAPI.cpp" />
<ClCompile Include="src\TF2Vulkan\IShaderAPI\ShaderAPI.cpp" />
<ClCompile Include="src\TF2Vulkan\ShaderDevice.cpp" />
<ClCompile Include="src\TF2Vulkan\ShaderDeviceMgr.cpp" />
<ClCompile Include="src\TF2Vulkan\ShaderNextFactory.cpp" />
Expand All @@ -171,7 +173,7 @@
<ClCompile Include="src\TF2Vulkan\ResourceBlob.cpp" />
<ClCompile Include="src\TF2Vulkan\VulkanFactories.cpp" />
<ClCompile Include="src\TF2Vulkan\StateManagerStatic.cpp" />
<ClCompile Include="src\TF2Vulkan\StateManagerDynamic.cpp" />
<ClCompile Include="src\TF2Vulkan\IShaderAPI\IShaderAPI_StateManagerDynamic.cpp" />
<ClCompile Include="src\TF2Vulkan\VertexFormat.cpp" />
<ClCompile Include="src\TF2Vulkan\vk_mem_alloc.cpp" />
<ClCompile Include="src\TF2Vulkan\VulkanMesh.cpp" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "IShaderAPI_MeshManager.h"

#include <materialsystem/imesh.h>

using namespace TF2Vulkan;

int IShaderAPI_MeshManager::GetMaxVerticesToRender(IMaterial* material)
{
LOG_FUNC();

VertexFormat fmt(material->GetVertexFormat());
fmt.RemoveFlags(VertexFormatFlags::Meta_Compressed);

const auto vtxSize = fmt.GetVertexSize();
const auto currentDynamicVBSize = GetCurrentDynamicVBSize();

if (vtxSize < 1)
{
Warning(TF2VULKAN_PREFIX "Invalid vertex size %i for material %s (%s)\n",
vtxSize, material->GetName(), material->GetShaderName());
return currentDynamicVBSize;
}

return currentDynamicVBSize / vtxSize;
}

int IShaderAPI_MeshManager::GetMaxIndicesToRender()
{
LOG_FUNC();

// Technically we're "unlimited" (constrained by (v)ram only)
return INDEX_BUFFER_SIZE;
}

int IShaderAPI_MeshManager::GetCurrentDynamicVBSize()
{
LOG_FUNC();
// Technically we're "unlimited" (constrained by (v)ram only)
return DYNAMIC_VERTEX_BUFFER_MEMORY;
}

IMesh* IShaderAPI_MeshManager::GetDynamicMesh(IMaterial* material, int hwSkinBoneCount,
bool buffered, IMesh* vertexOverride, IMesh* indexOverride)
{
LOG_FUNC();
return GetDynamicMeshEx(material, material->GetVertexFormat(), hwSkinBoneCount, buffered, vertexOverride, indexOverride);
}

IMesh* IShaderAPI_MeshManager::GetDynamicMeshEx(IMaterial* material, VertexFormat_t vertexFormat,
int hwSkinBoneCount, bool buffered, IMesh* vertexOverride, IMesh* indexOverride)
{
LOG_FUNC();

const VertexFormat fmt(vertexFormat);
assert(hwSkinBoneCount == 0);
assert(fmt.m_BoneWeightCount == 0);
assert(!(fmt.m_Flags & VertexFormatFlags::BoneIndex));

return &m_DynamicMeshes.try_emplace(fmt, fmt, true).first->second;
}

CMeshBuilder* IShaderAPI_MeshManager::GetVertexModifyBuilder()
{
LOG_FUNC();
return &m_MeshBuilder;
}
39 changes: 39 additions & 0 deletions shaderapivulkan/src/TF2Vulkan/IShaderAPI/IShaderAPI_MeshManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include "IShaderAPI_TextureManager.h"
#include "TF2Vulkan/VertexFormat.h"
#include "TF2Vulkan/VulkanMesh.h"

namespace TF2Vulkan
{
class IShaderAPI_MeshManager : public IShaderAPI_TextureManager
{
public:
void GetMaxToRender(IMesh* mesh, bool maxUntilFlush, int* maxVerts, int* maxIndices) override final { NOT_IMPLEMENTED_FUNC(); }

int GetMaxVerticesToRender(IMaterial* material) override final;
int GetMaxIndicesToRender() override final;

IMesh* GetFlexMesh() override final { NOT_IMPLEMENTED_FUNC(); }

int GetCurrentDynamicVBSize() override final;
void DestroyVertexBuffers(bool exitingLevel) override final { NOT_IMPLEMENTED_FUNC(); }

CMeshBuilder* GetVertexModifyBuilder() override final;
IMesh* GetDynamicMesh(IMaterial* material, int hwSkinBoneCount, bool buffered,
IMesh* vertexOverride, IMesh* indexOverride) override final;
IMesh* GetDynamicMeshEx(IMaterial* material, VertexFormat_t vertexFormat, int hwSkinBoneCount,
bool buffered, IMesh* vertexOverride, IMesh* indexOverride) override final;

const ActiveMeshData& GetActiveMesh() override final { return m_ActiveMesh.top(); }
void PushActiveMesh(const ActiveMeshData& mesh) override final { m_ActiveMesh.push(mesh); }
void PopActiveMesh() override final { m_ActiveMesh.pop(); }

private:
std::unordered_map<VertexFormat, VulkanMesh> m_DynamicMeshes;

CMeshBuilder m_MeshBuilder;

std::stack<ActiveMeshData, std::vector<ActiveMeshData>> m_ActiveMesh;
};
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "stdafx.h"
#include "StateManagerDynamic.h"
#include "IShaderAPI_StateManagerDynamic.h"
#include "interface/IMaterialInternal.h"
#include "interface/internal/IShaderInternal.h"
#include "interface/internal/IStateManagerStatic.h"
#include "shaders/VulkanShaderManager.h"
#include "TF2Vulkan/shaders/VulkanShaderManager.h"

#include <TF2Vulkan/Util/Color.h>
#include <TF2Vulkan/Util/DirtyVar.h>
Expand Down Expand Up @@ -193,8 +193,21 @@ const Vector& IShaderAPI_StateManagerDynamic::GetToneMappingScaleLinear() const
return m_State.m_TonemappingScale;
}

void IShaderAPI_StateManagerDynamic::EnableUserClipTransformOverride(bool enable)
{
LOG_FUNC();
Util::SetDirtyVar(m_State.m_UserClipTransformOverrideEnabled, enable, m_Dirty);
}

void IShaderAPI_StateManagerDynamic::UserClipTransform(const VMatrix& worldToView)
{
LOG_FUNC();
Util::SetDirtyVar(m_State.m_UserClipTransformOverride, worldToView, m_Dirty);
}

void IShaderAPI_StateManagerDynamic::SetShaderInstance(ShaderType type, const IShaderInstance* instance)
{
assert(instance->GetGroup().GetShaderType() == type);
switch (type)
{
case ShaderType::Pixel:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "LogicalState.h"
#include "IShaderTextureManager.h"
#include "TF2Vulkan/LogicalState.h"
#include "IShaderAPI_MeshManager.h"

#include <TF2Vulkan/IShaderDynamicNext.h>
#include <TF2Vulkan/Util/InPlaceVector.h>
Expand All @@ -14,9 +14,9 @@

namespace TF2Vulkan
{
class IShaderAPI_StateManagerDynamic : public IShaderTextureManager, public IShaderDynamicNext
class IShaderAPI_StateManagerDynamic : public IShaderAPI_MeshManager, public IShaderDynamicNext
{
using BaseClass = IShaderTextureManager;
using BaseClass = IShaderAPI_TextureManager;

public:
IShaderAPI_StateManagerDynamic();
Expand Down Expand Up @@ -135,6 +135,9 @@ namespace TF2Vulkan
const Vector& GetToneMappingScaleLinear(void) const override final;
float GetLightMapScaleFactor(void) const override final { NOT_IMPLEMENTED_FUNC(); }

void EnableUserClipTransformOverride(bool enable) override final;
void UserClipTransform(const VMatrix& worldToView) override final;

// IShaderDynamicNext
void SetShaderInstance(ShaderType type, const IShaderInstance* instance) override final;
void BindUniformBuffer(const BufferPoolEntry& buf, UniformBufferIndex index) override final;
Expand All @@ -145,7 +148,6 @@ namespace TF2Vulkan
const LogicalDynamicState& GetDynamicState() const { return m_State; }

private:

MaterialMatrixMode_t m_MatrixMode = {};
using MatrixStack = std::stack<VMatrix, std::vector<VMatrix>>;
std::array<MatrixStack, NUM_MATRIX_MODES> m_MatrixStacks;
Expand Down
Loading

0 comments on commit ea05907

Please sign in to comment.