feat: Implement initial Metal graphics device with comprehensive shader system and pipeline management.

This commit is contained in:
aomizu 2025-12-23 17:50:14 +09:00
parent 81970958a8
commit 1ad3679f90
3 changed files with 1201 additions and 77 deletions

View File

@ -11,6 +11,7 @@
#include "glue/CGlueMgr.hpp"
#include "glue/GlueScriptEvents.hpp"
#include "gx/Screen.hpp"
#include "gx/Shader.hpp"
#include "gx/Texture.hpp"
#include "model/Model2.hpp"
#include "net/Poll.hpp"
@ -235,6 +236,7 @@ int32_t InitializeEngineCallback(const void* a1, void* a2) {
auto m2Flags = M2RegisterCVars();
M2Initialize(m2Flags, 0);
CShaderEffect::InitShaderSystem((M2GetCacheFlags() & 0x8) != 0, 0);
// v4 = *(_DWORD *)(dword_B2FA00 + 48);
// sub_4B61C0(dword_AB6128[v4]);

View File

@ -32,6 +32,7 @@ class CGxDeviceMTL : public CGxDevice {
void IShaderCreate(CGxShader*) override;
void ShaderCreate(CGxShader*[], EGxShTarget, const char*, const char*, int32_t) override;
int32_t StereoEnabled(void) override;
void XformSetProjection(const C44Matrix& matrix) override;
// Member functions
CGxDeviceMTL();
@ -39,15 +40,42 @@ class CGxDeviceMTL : public CGxDevice {
private:
void ISetCaps(const CGxFormat& format);
void EnsureDebugPipeline();
void EnsureLibrary();
void BeginFrame();
void* GetPipeline(EGxVertexBufferFormat format, bool useColor, bool useSkin, bool useTex, int32_t blendMode);
void* GetPoolBuffer(CGxPool* pool);
void ITexCreate(CGxTex* texId);
void ITexUpload(CGxTex* texId);
void* GetTexture(CGxTex* texId);
void* GetSampler(CGxTex* texId);
void EnsureFallbackTexture();
void EnsureDepthTexture(uint32_t width, uint32_t height);
void* GetDepthState(bool depthTest, bool depthWrite, uint32_t depthFunc);
void* m_device = nullptr;
void* m_commandQueue = nullptr;
void* m_layer = nullptr;
void* m_pipeline = nullptr;
void* m_vertexBuffer = nullptr;
uint32_t m_vertexCount = 0;
void* m_shaderLibrary = nullptr;
void* m_pipelineColor[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSolid[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSkin[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineColorTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSolidTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSkinTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineColorTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSolidTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSkinTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_frameCommandBuffer = nullptr;
void* m_frameEncoder = nullptr;
void* m_frameDrawable = nullptr;
uint32_t m_frameHasDraw = 0;
uint32_t m_clearMask = 0;
uint32_t m_clearColor = 0;
void* m_fallbackTexture = nullptr;
void* m_fallbackSampler = nullptr;
void* m_depthTexture = nullptr;
uint32_t m_depthWidth = 0;
uint32_t m_depthHeight = 0;
void* m_depthStates[2][2][4] = {};
};
#endif

File diff suppressed because it is too large Load Diff