Remove Gfx Driver Vertex and IndexBuffer size config
This commit is contained in:
@@ -11,9 +11,6 @@ struct GfxCitro3DConfig {
|
|||||||
// Index Allocator
|
// Index Allocator
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using IndexAlloc = LinearAllocator<T>;
|
using IndexAlloc = LinearAllocator<T>;
|
||||||
|
|
||||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
|
||||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GfxCitro3D : public GfxDriverBase<GfxCitro3DConfig> {
|
class GfxCitro3D : public GfxDriverBase<GfxCitro3DConfig> {
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ struct GfxDirectX9Config {
|
|||||||
// Index Allocator
|
// Index Allocator
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using IndexAlloc = std::allocator<T>;
|
using IndexAlloc = std::allocator<T>;
|
||||||
|
|
||||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
|
||||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GfxDirectX9 : public GfxDriverBase<GfxDirectX9Config> {
|
class GfxDirectX9 : public GfxDriverBase<GfxDirectX9Config> {
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ struct GfxOpenGL2Config {
|
|||||||
// Index Allocator
|
// Index Allocator
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using IndexAlloc = std::allocator<T>;
|
using IndexAlloc = std::allocator<T>;
|
||||||
|
|
||||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
|
||||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GfxOpenGL2 : public GfxDriverBase<GfxOpenGL2Config> {
|
class GfxOpenGL2 : public GfxDriverBase<GfxOpenGL2Config> {
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ struct GfxOpenGL3Config {
|
|||||||
// Index Allocator
|
// Index Allocator
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using IndexAlloc = std::allocator<T>;
|
using IndexAlloc = std::allocator<T>;
|
||||||
|
|
||||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
|
||||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GfxOpenGL3 : public GfxDriverBase<GfxOpenGL3Config> {
|
class GfxOpenGL3 : public GfxDriverBase<GfxOpenGL3Config> {
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ struct GfxDirectX9::Impl {
|
|||||||
IDirect3DVertexShader9* VS = nullptr;
|
IDirect3DVertexShader9* VS = nullptr;
|
||||||
IDirect3DPixelShader9* FS = nullptr;
|
IDirect3DPixelShader9* FS = nullptr;
|
||||||
IDirect3DTexture9* CurrentTex = nullptr;
|
IDirect3DTexture9* CurrentTex = nullptr;
|
||||||
|
size_t VertexBufferSize = 0;
|
||||||
|
size_t IndexBufferSize = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GfxDirectX9::SysInit() {
|
void GfxDirectX9::SysInit() {
|
||||||
@@ -78,14 +80,7 @@ void GfxDirectX9::SysInit() {
|
|||||||
0},
|
0},
|
||||||
D3DDECL_END()};
|
D3DDECL_END()};
|
||||||
impl->Device->CreateVertexDeclaration(elements, &impl->Decl);
|
impl->Device->CreateVertexDeclaration(elements, &impl->Decl);
|
||||||
impl->Device->CreateVertexBuffer(
|
|
||||||
GfxDirectX9Config::NumVertices * sizeof(PD::Li::Vertex),
|
|
||||||
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &impl->VBO,
|
|
||||||
nullptr);
|
|
||||||
impl->Device->CreateIndexBuffer(GfxDirectX9Config::NumIndices * sizeof(u16),
|
|
||||||
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
|
|
||||||
D3DFMT_INDEX16, D3DPOOL_DEFAULT, &impl->IBO,
|
|
||||||
nullptr);
|
|
||||||
ID3DBlob* vsBlob = nullptr;
|
ID3DBlob* vsBlob = nullptr;
|
||||||
ID3DBlob* errBlob = nullptr;
|
ID3DBlob* errBlob = nullptr;
|
||||||
HRESULT hr = D3DCompile(g_vsCode, strlen(g_vsCode), nullptr, nullptr,
|
HRESULT hr = D3DCompile(g_vsCode, strlen(g_vsCode), nullptr, nullptr,
|
||||||
@@ -140,6 +135,32 @@ void GfxDirectX9::Submit(size_t count, size_t start) {
|
|||||||
impl->Device->SetVertexShaderConstantF(
|
impl->Device->SetVertexShaderConstantF(
|
||||||
0, reinterpret_cast<const float*>(&Projection), 4);
|
0, reinterpret_cast<const float*>(&Projection), 4);
|
||||||
|
|
||||||
|
if (!impl->VBO || impl->VertexBufferSize != GetVertexPoolSize()) {
|
||||||
|
if (impl->VBO) {
|
||||||
|
impl->VBO->Release();
|
||||||
|
impl->VBO = nullptr;
|
||||||
|
impl->VertexBufferSize = 0;
|
||||||
|
}
|
||||||
|
if (impl->Device->CreateVertexBuffer(
|
||||||
|
GetVertexPoolSize() * sizeof(Li::Vertex),
|
||||||
|
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT,
|
||||||
|
&impl->VBO, nullptr) < 0)
|
||||||
|
return;
|
||||||
|
impl->VertexBufferSize = GetVertexPoolSize();
|
||||||
|
}
|
||||||
|
if (!impl->IBO || impl->IndexBufferSize != GetIndexPoolSize()) {
|
||||||
|
if (impl->IBO) {
|
||||||
|
impl->IBO->Release();
|
||||||
|
impl->IBO = nullptr;
|
||||||
|
impl->IndexBufferSize = 0;
|
||||||
|
}
|
||||||
|
if (impl->Device->CreateIndexBuffer(GetVertexPoolSize() * sizeof(u16),
|
||||||
|
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
|
||||||
|
D3DFMT_INDEX16, D3DPOOL_DEFAULT,
|
||||||
|
&impl->IBO, nullptr) < 0)
|
||||||
|
return;
|
||||||
|
impl->IndexBufferSize = GetIndexPoolSize();
|
||||||
|
}
|
||||||
void* vptr;
|
void* vptr;
|
||||||
impl->VBO->Lock(0, 0, &vptr, D3DLOCK_DISCARD);
|
impl->VBO->Lock(0, 0, &vptr, D3DLOCK_DISCARD);
|
||||||
memcpy(vptr, GetVertexBufPtr(0), CurrentVertex * sizeof(PD::Li::Vertex));
|
memcpy(vptr, GetVertexBufPtr(0), CurrentVertex * sizeof(PD::Li::Vertex));
|
||||||
|
|||||||
+11
-10
@@ -5,10 +5,11 @@
|
|||||||
#include <pd/lithium/command.hpp>
|
#include <pd/lithium/command.hpp>
|
||||||
#include <pd/lithium/texture.hpp>
|
#include <pd/lithium/texture.hpp>
|
||||||
|
|
||||||
using LiBackendFlags = PD::u32;
|
using PDBackendFlags = PD::u32;
|
||||||
enum LiBackendFlags_ {
|
enum PDBackendFlags_ {
|
||||||
LiBackendFlags_None = 0,
|
PDBackendFlags_None = 0,
|
||||||
LiBackendFlags_FlipUV_Y = 1 << 0, // Essential for font loading
|
PDBackendFlags_FlipUV_Y = 1 << 0, // Essential for font loading
|
||||||
|
PDBackendFlags_WindingCW = 1 << 0, // Use CW instead of CCW winding
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -20,7 +21,10 @@ class PD_API GfxDriver : public DriverInterface {
|
|||||||
virtual ~GfxDriver();
|
virtual ~GfxDriver();
|
||||||
|
|
||||||
virtual void Init() {}
|
virtual void Init() {}
|
||||||
virtual void Deinit() { SysDeinit(); }
|
virtual void Deinit() {
|
||||||
|
DeleteTexture(pWhite);
|
||||||
|
SysDeinit();
|
||||||
|
}
|
||||||
|
|
||||||
void SetViewPort(const ivec2& size);
|
void SetViewPort(const ivec2& size);
|
||||||
void SetViewPort(int x, int y);
|
void SetViewPort(int x, int y);
|
||||||
@@ -66,9 +70,6 @@ struct DefaultGfxConfig {
|
|||||||
// Index Allocator
|
// Index Allocator
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using IndexAlloc = std::allocator<T>;
|
using IndexAlloc = std::allocator<T>;
|
||||||
|
|
||||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
|
||||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Config = DefaultGfxConfig>
|
template <typename Config = DefaultGfxConfig>
|
||||||
@@ -81,8 +82,6 @@ class GfxDriverBase : public GfxDriver {
|
|||||||
virtual ~GfxDriverBase() {}
|
virtual ~GfxDriverBase() {}
|
||||||
|
|
||||||
void Init() override {
|
void Init() override {
|
||||||
// pVtxPool.Init(Config::NumVertices);
|
|
||||||
// pIdxPool.Init(Config::NumIndices);
|
|
||||||
SysInit();
|
SysInit();
|
||||||
std::vector<u8> img(16 * 16 * 4, 0xff);
|
std::vector<u8> img(16 * 16 * 4, 0xff);
|
||||||
pWhite = LoadTexture(img, 16, 16);
|
pWhite = LoadTexture(img, 16, 16);
|
||||||
@@ -122,6 +121,8 @@ class GfxDriverBase : public GfxDriver {
|
|||||||
protected:
|
protected:
|
||||||
u16* GetIndexBufPtr(size_t start) { return &pIdxPool[start]; }
|
u16* GetIndexBufPtr(size_t start) { return &pIdxPool[start]; }
|
||||||
Li::Vertex* GetVertexBufPtr(size_t start) { return &pVtxPool[start]; }
|
Li::Vertex* GetVertexBufPtr(size_t start) { return &pVtxPool[start]; }
|
||||||
|
size_t GetVertexPoolSize() const { return pVtxPool.size(); }
|
||||||
|
size_t GetIndexPoolSize() const { return pIdxPool.size(); }
|
||||||
void ResetPools() override {
|
void ResetPools() override {
|
||||||
pVtxPool.Reset();
|
pVtxPool.Reset();
|
||||||
pIdxPool.Reset();
|
pIdxPool.Reset();
|
||||||
|
|||||||
Vendored
+1
-1
Submodule vendor/spirv-helper updated: e05a0a45c2...91f57a5101
Reference in New Issue
Block a user