Skip to content

Commit

Permalink
main menu badges are working, lads
Browse files Browse the repository at this point in the history
  • Loading branch information
PazerOP committed May 20, 2019
1 parent e9e23eb commit eebbd7d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 30 deletions.
2 changes: 0 additions & 2 deletions shaderapivulkan/src/TF2Vulkan/LogicalState.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ namespace TF2Vulkan
{
constexpr LogicalDynamicState() = default;

std::array<VMatrix, NUM_MATRIX_MODES> m_Matrices;

bool m_InFlashlightMode = false;
IMaterial* m_BoundMaterial = nullptr;
int m_BoneCount = 0;
Expand Down
4 changes: 3 additions & 1 deletion shaderapivulkan/src/TF2Vulkan/ShaderAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ IMesh* ShaderAPI::GetDynamicMesh(IMaterial* material, int hwSkinBoneCount,
{
LOG_FUNC();
return GetDynamicMeshEx(material, material->GetVertexFormat(), hwSkinBoneCount, buffered, vertexOverride, indexOverride);
const VertexFormat fmt(material->GetVertexFormat());
}

IMesh* ShaderAPI::GetDynamicMeshEx(IMaterial* material, VertexFormat_t vertexFormat,
Expand All @@ -430,6 +429,9 @@ IMesh* ShaderAPI::GetDynamicMeshEx(IMaterial* material, VertexFormat_t vertexFor
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;
}
Expand Down
3 changes: 3 additions & 0 deletions shaderapivulkan/src/TF2Vulkan/ShaderDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ IMesh* ShaderDevice::CreateStaticMesh(VertexFormat_t format, const char* texture
{
// TODO
NOT_IMPLEMENTED_FUNC_NOBREAK();

const VertexFormat fmt(format);
assert(fmt.m_BoneWeightCount == 0);
return new VulkanMesh(VertexFormat(format), false);
}

Expand Down
35 changes: 20 additions & 15 deletions shaderapivulkan/src/TF2Vulkan/StateManagerDynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ void IShaderAPI_StateManagerDynamic::BindTexture(Sampler_t sampler, ShaderAPITex
Util::SetDirtyVar(m_State.m_BoundTextures, sampler, textureHandle, m_Dirty);
}

IShaderAPI_StateManagerDynamic::IShaderAPI_StateManagerDynamic()
{
//for (auto& stack : m_MatrixStacks)
// stack.emplace().Identity();
}

void IShaderAPI_StateManagerDynamic::SetViewports(int count, const ShaderViewport_t* viewports)
{
LOG_FUNC();
Expand Down Expand Up @@ -250,42 +256,41 @@ void IShaderAPI_StateManagerDynamic::GetMatrix(MaterialMatrixMode_t mode, float*
void IShaderAPI_StateManagerDynamic::GetMatrix(MaterialMatrixMode_t mode, VMatrix & dst) const
{
LOG_FUNC();
dst = m_State.m_Matrices.at(mode);
}
auto& stack = m_MatrixStacks.at(mode);

void IShaderAPI_StateManagerDynamic::AssertMatrixMode()
{
assert(m_MatrixMode >= 0);
assert(m_MatrixMode < NUM_MATRIX_MODES);
if (!stack.empty())
dst = stack.top();
else
dst.Identity();
}

void IShaderAPI_StateManagerDynamic::PushMatrix()
{
LOG_FUNC();

auto& stack = m_MatrixStacks.at(m_MatrixMode);
auto& mat = m_State.m_Matrices.at(m_MatrixMode);
stack.emplace(mat);

if (!stack.empty())
stack.push(stack.top());
else
stack.emplace().Identity();
}

void IShaderAPI_StateManagerDynamic::PopMatrix()
{
LOG_FUNC();

auto& mat = m_State.m_Matrices.at(m_MatrixMode);
auto& stack = m_MatrixStacks.at(m_MatrixMode);

mat = stack.top();
m_Dirty = true;

stack.pop();
if (!stack.empty())
stack.pop();
}

void IShaderAPI_StateManagerDynamic::LoadIdentity()
{
LOG_FUNC();

m_State.m_Matrices.at(m_MatrixMode).Identity();
m_MatrixStacks.at(m_MatrixMode).top().Identity();
m_Dirty = true;
}

Expand All @@ -298,7 +303,7 @@ void IShaderAPI_StateManagerDynamic::LoadMatrix(float* m)
void IShaderAPI_StateManagerDynamic::LoadMatrix(const VMatrix & m)
{
LOG_FUNC();
Util::SetDirtyVar(m_State.m_Matrices.at(m_MatrixMode), m, m_Dirty);
Util::SetDirtyVar(m_MatrixStacks.at(m_MatrixMode).top(), m, m_Dirty);
}

void IShaderAPI_StateManagerDynamic::MultMatrix(float* m)
Expand Down
5 changes: 3 additions & 2 deletions shaderapivulkan/src/TF2Vulkan/StateManagerDynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace TF2Vulkan
using BaseClass = IShaderTextureManager;

public:
IShaderAPI_StateManagerDynamic();

void SetViewports(int count, const ShaderViewport_t* viewports) override final;
int GetViewports(ShaderViewport_t* viewports, int maxViewports) const override final { NOT_IMPLEMENTED_FUNC(); }
Expand Down Expand Up @@ -144,10 +145,10 @@ namespace TF2Vulkan
const LogicalDynamicState& GetDynamicState() const { return m_State; }

private:
void AssertMatrixMode();

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

LogicalDynamicState m_State;
bool m_Dirty = true;
Expand Down
13 changes: 8 additions & 5 deletions shaderapivulkan/src/TF2Vulkan/StateManagerVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,11 @@ Pipeline::Pipeline(const PipelineKey& key, const PipelineLayout& layout,

// Scissor(s)
{
m_Scissor.extent.width = m_ViewportStateCI.pViewports[0].width;
m_Scissor.extent.height = m_ViewportStateCI.pViewports[0].height;
const auto& vp = m_ViewportStateCI.pViewports[0];
m_Scissor.offset.x = vp.x;
m_Scissor.offset.y = vp.y;
m_Scissor.extent.width = vp.width;
m_Scissor.extent.height = vp.height;
m_ViewportStateCI.pScissors = &m_Scissor;
m_ViewportStateCI.scissorCount = 1;
}
Expand Down Expand Up @@ -865,9 +868,9 @@ Pipeline::Pipeline(const PipelineKey& key, const PipelineLayout& layout,
auto& ci = m_DepthStencilStateCI;
m_CreateInfo.pDepthStencilState = &ci;

ci.depthTestEnable = false;// key.m_DepthTest;
//ci.depthWriteEnable = key.m_DepthWrite;
//ci.depthCompareOp = ConvertCompareOp(key.m_DepthCompareFunc);
ci.depthTestEnable = key.m_DepthTest;
ci.depthWriteEnable = key.m_DepthWrite;
ci.depthCompareOp = ConvertCompareOp(key.m_DepthCompareFunc);
}

// Graphics pipeline
Expand Down
3 changes: 3 additions & 0 deletions stdshader_dx9_tf2vulkan/src/HLSL/xlitgeneric.frag.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ float4 main(const PS_INPUT i) : SV_Target
if (TEXACTIVE_BASETEXTURE)
baseTextureColor = BaseTexture.Sample(BaseTextureSampler, i.baseTexCoord.xy);

if (DIFFUSELIGHTING)
return baseTextureColor;

const float3 finalColor = diffuseColor.rgb * baseTextureColor.rgb;
const float finalAlpha = lerp(baseTextureColor.a, baseTextureColor.a * i.color.a, g_fVertexAlpha);
return float4(finalColor, finalAlpha);
Expand Down
11 changes: 6 additions & 5 deletions stdshader_vulkan/src/shaders/XLitGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ inline namespace XLitGeneric

SpecConstBuf m_SpecConsts;
VertexFormat m_Format;
ShaderDataCommon m_UniformsCommon;
VSModelMatrices m_ModelMatrices;
UniformBuf m_Uniforms;
ShaderDataCommon m_UniformsCommon{};
VSModelMatrices m_ModelMatrices{};
UniformBuf m_Uniforms{};

bool m_UsingBaseTexture = false;
bool m_UsingRefraction = false;
Expand Down Expand Up @@ -537,15 +537,16 @@ void Shader::OnDrawElements(const OnDrawElementsParams& params)
dynamic->GetMatrix(MATERIAL_VIEW, view);
dynamic->GetMatrix(MATERIAL_PROJECTION, proj);

common.m_ViewProj = proj * view;
common.m_ModelViewProj = (common.m_ViewProj * model).Transpose();
common.m_ViewProj = view * proj;
common.m_ModelViewProj = (model * common.m_ViewProj).Transpose();
common.m_ViewProj = common.m_ViewProj.Transpose();
}

// Model matrices
{
VMatrix tmp;
dynamic->GetMatrix(MATERIAL_MODEL, tmp);
//assert(tmp.IsIdentity());
modelMats.m_Model[0] = tmp.Transpose().As3x4();
}

Expand Down

0 comments on commit eebbd7d

Please sign in to comment.