mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-12 18:46:10 +00:00
Start wiring up wgpu+winit
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "Shaders/shader_CFluidPlaneShader.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
@@ -53,34 +53,34 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
struct ShaderPair {
|
||||
boo::ObjToken<boo::IShaderPipeline> m_regular;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_tessellation;
|
||||
void reset() {
|
||||
m_regular.reset();
|
||||
m_tessellation.reset();
|
||||
}
|
||||
};
|
||||
// struct ShaderPair {
|
||||
// boo::ObjToken<boo::IShaderPipeline> m_regular;
|
||||
// boo::ObjToken<boo::IShaderPipeline> m_tessellation;
|
||||
// void reset() {
|
||||
// m_regular.reset();
|
||||
// m_tessellation.reset();
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// struct BindingPair {
|
||||
// boo::ObjToken<boo::IShaderDataBinding> m_regular;
|
||||
// boo::ObjToken<boo::IShaderDataBinding> m_tessellation;
|
||||
// };
|
||||
|
||||
struct BindingPair {
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_regular;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_tessellation;
|
||||
};
|
||||
|
||||
class Cache {
|
||||
std::array<ShaderPair, 1024> m_cache{};
|
||||
std::array<ShaderPair, 8> m_doorCache{};
|
||||
ShaderPair& CacheSlot(const SFluidPlaneShaderInfo& info, int i) { return m_cache[i]; }
|
||||
ShaderPair& CacheSlot(const SFluidPlaneDoorShaderInfo& info, int i) { return m_doorCache[i]; }
|
||||
static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info);
|
||||
static u16 MakeCacheKey(const SFluidPlaneDoorShaderInfo& info);
|
||||
|
||||
public:
|
||||
template <class T>
|
||||
ShaderPair GetOrBuildShader(const T& info);
|
||||
void Clear();
|
||||
};
|
||||
static Cache _cache;
|
||||
// class Cache {
|
||||
// std::array<ShaderPair, 1024> m_cache{};
|
||||
// std::array<ShaderPair, 8> m_doorCache{};
|
||||
// ShaderPair& CacheSlot(const SFluidPlaneShaderInfo& info, int i) { return m_cache[i]; }
|
||||
// ShaderPair& CacheSlot(const SFluidPlaneDoorShaderInfo& info, int i) { return m_doorCache[i]; }
|
||||
// static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info);
|
||||
// static u16 MakeCacheKey(const SFluidPlaneDoorShaderInfo& info);
|
||||
//
|
||||
// public:
|
||||
// template <class T>
|
||||
// ShaderPair GetOrBuildShader(const T& info);
|
||||
// void Clear();
|
||||
// };
|
||||
// static Cache _cache;
|
||||
|
||||
struct Ripple {
|
||||
zeus::CVector4f center; // time, distFalloff
|
||||
@@ -106,34 +106,34 @@ private:
|
||||
TLockedToken<CTexture> m_envMap;
|
||||
TLockedToken<CTexture> m_envBumpMap;
|
||||
TLockedToken<CTexture> m_lightmap;
|
||||
boo::ObjToken<boo::ITextureS> m_rippleMap;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_pvbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
ShaderPair m_pipelines;
|
||||
BindingPair m_dataBind;
|
||||
std::shared_ptr<aurora::TextureHandle> m_rippleMap;
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_pvbo;
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
// ShaderPair m_pipelines;
|
||||
// BindingPair m_dataBind;
|
||||
int m_lastBind = -1;
|
||||
|
||||
#if BOO_HAS_GL
|
||||
static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
BindingPair BuildBinding(boo::GLDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
#endif
|
||||
#if _WIN32
|
||||
static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
BindingPair BuildBinding(boo::D3D11DataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
BindingPair BuildBinding(boo::MetalDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
BindingPair BuildBinding(boo::VulkanDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
#endif
|
||||
//#if BOO_HAS_GL
|
||||
// static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
// static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
// BindingPair BuildBinding(boo::GLDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
//#endif
|
||||
//#if _WIN32
|
||||
// static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
// static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
// BindingPair BuildBinding(boo::D3D11DataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
//#endif
|
||||
//#if BOO_HAS_METAL
|
||||
// static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
// static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
// BindingPair BuildBinding(boo::MetalDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
//#endif
|
||||
//#if BOO_HAS_VULKAN
|
||||
// static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
// static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
// BindingPair BuildBinding(boo::VulkanDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
//#endif
|
||||
|
||||
template <class F>
|
||||
static void _Shutdown();
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
|
||||
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
|
||||
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
|
||||
const boo::ObjToken<boo::ITextureS>& rippleMap, bool doubleLightmapBlend, bool additive,
|
||||
const std::shared_ptr<aurora::TextureHandle>& rippleMap, bool doubleLightmapBlend, bool additive,
|
||||
u32 maxVertCount);
|
||||
CFluidPlaneShader(const TLockedToken<CTexture>& patternTex1, const TLockedToken<CTexture>& patternTex2,
|
||||
const TLockedToken<CTexture>& colorTex, u32 maxVertCount);
|
||||
@@ -154,13 +154,13 @@ public:
|
||||
const zeus::CColor& colorMul, float rippleNormResolution);
|
||||
void bindRegular() {
|
||||
if (m_lastBind != 0) {
|
||||
CGraphics::SetShaderDataBinding(m_dataBind.m_regular);
|
||||
// CGraphics::SetShaderDataBinding(m_dataBind.m_regular);
|
||||
m_lastBind = 0;
|
||||
}
|
||||
}
|
||||
bool bindTessellation() {
|
||||
if (m_lastBind != 1) {
|
||||
CGraphics::SetShaderDataBinding(m_dataBind.m_tessellation);
|
||||
// CGraphics::SetShaderDataBinding(m_dataBind.m_tessellation);
|
||||
m_lastBind = 1;
|
||||
}
|
||||
return true;
|
||||
@@ -168,7 +168,8 @@ public:
|
||||
void doneDrawing() { m_lastBind = -1; }
|
||||
void loadVerts(const std::vector<Vertex>& verts, const std::vector<PatchVertex>& pVerts);
|
||||
bool isReady() const {
|
||||
return m_pipelines.m_regular->isReady() && (!m_pipelines.m_tessellation || m_pipelines.m_tessellation->isReady());
|
||||
// return m_pipelines.m_regular->isReady() && (!m_pipelines.m_tessellation || m_pipelines.m_tessellation->isReady());
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
Reference in New Issue
Block a user