mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2026-11-20 21:14:29 +03:00
feat(gx): implement draw calls in d3d backend
This commit is contained in:
1 parent
34c7593ddb
commit
d869c6d898
4 files changed
+78
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#include "gx/d3d/CGxDeviceD3d.hpp"
|
||||
#include "gx/CGxBatch.hpp"
|
||||
#include "gx/texture/CGxTex.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
@@ -55,6 +56,15 @@ EGxTexFormat CGxDeviceD3d::s_GxTexFmtToUse[] = {
|
||||
GxTex_D24X8,
|
||||
};
|
||||
|
||||
D3DPRIMITIVETYPE CGxDeviceD3d::s_primitiveConversion[] = {
|
||||
D3DPT_POINTLIST, // GxPrim_Points
|
||||
D3DPT_LINELIST, // GxPrim_Lines
|
||||
D3DPT_LINESTRIP, // GxPrim_LineStrip
|
||||
D3DPT_TRIANGLELIST, // GxPrim_Triangles
|
||||
D3DPT_TRIANGLESTRIP, // GxPrim_TriangleStrip
|
||||
D3DPT_TRIANGLEFAN, // GxPrim_TriangleFan
|
||||
};
|
||||
|
||||
EGxTexFormat CGxDeviceD3d::s_tolerableTexFmtMapping[] = {
|
||||
GxTex_Unknown, // GxTex_Unknown
|
||||
GxTex_Argb4444, // GxTex_Abgr8888
|
||||
@@ -347,6 +357,36 @@ void CGxDeviceD3d::DeviceWM(EGxWM wm, uintptr_t param1, uintptr_t param2) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::Draw(CGxBatch* batch, int32_t count) {
|
||||
if (!this->m_context || this->intF5C) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->IStateSync();
|
||||
|
||||
int32_t baseIndex = 0;
|
||||
if (!this->m_caps.int10) {
|
||||
baseIndex = this->m_primVertexFormatBuf[0]->m_index / this->m_primVertexFormatBuf[0]->m_itemSize;
|
||||
}
|
||||
|
||||
if (count) {
|
||||
this->m_d3dDevice->DrawIndexedPrimitive(
|
||||
CGxDeviceD3d::s_primitiveConversion[batch->m_primType],
|
||||
baseIndex,
|
||||
batch->m_minIndex,
|
||||
batch->m_maxIndex - batch->m_minIndex + 1,
|
||||
batch->m_start + (this->m_primIndexBuf->m_index / 2),
|
||||
CGxDevice::PrimCalcCount(batch->m_primType, batch->m_count)
|
||||
);
|
||||
} else {
|
||||
this->m_d3dDevice->DrawPrimitive(
|
||||
CGxDeviceD3d::s_primitiveConversion[batch->m_primType],
|
||||
baseIndex,
|
||||
CGxDevice::PrimCalcCount(batch->m_primType, batch->m_count)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::DsSet(EDeviceState state, uint32_t val) {
|
||||
// TODO
|
||||
}
|
||||
@@ -883,6 +923,10 @@ void CGxDeviceD3d::IShaderCreateVertex(CGxShader* shader) {
|
||||
}
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::IStateSync() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::ITexCreate(CGxTex* texId) {
|
||||
uint32_t width, height, startLevel, endLevel;
|
||||
this->ITexWHDStartEnd(texId, width, height, startLevel, endLevel);
|
||||
|
||||
@@ -200,6 +200,7 @@ class CGxDeviceD3d : public CGxDevice {
|
||||
static D3DFORMAT s_GxFormatToD3dFormat[];
|
||||
static D3DFORMAT s_GxTexFmtToD3dFmt[];
|
||||
static EGxTexFormat s_GxTexFmtToUse[];
|
||||
static D3DPRIMITIVETYPE s_primitiveConversion[];
|
||||
static EGxTexFormat s_tolerableTexFmtMapping[];
|
||||
static D3DTEXTUREADDRESS s_wrapModes[];
|
||||
|
||||
@@ -229,6 +230,7 @@ class CGxDeviceD3d : public CGxDevice {
|
||||
virtual void DeviceWM(EGxWM wm, uintptr_t param1, uintptr_t param2);
|
||||
virtual void CapsWindowSize(CRect& dst);
|
||||
virtual void CapsWindowSizeInScreenCoords(CRect& dst);
|
||||
virtual void Draw(CGxBatch* batch, int32_t count);
|
||||
virtual void PoolSizeSet(CGxPool* pool, uint32_t size);
|
||||
virtual char* BufLock(CGxBuf* buf);
|
||||
virtual int32_t BufUnlock(CGxBuf* buf, uint32_t size);
|
||||
@@ -254,6 +256,7 @@ class CGxDeviceD3d : public CGxDevice {
|
||||
void ISetTexture(uint32_t tmu, CGxTex* texId);
|
||||
void IShaderCreatePixel(CGxShader* shader);
|
||||
void IShaderCreateVertex(CGxShader* shader);
|
||||
void IStateSync();
|
||||
void ITexCreate(CGxTex* texId);
|
||||
void ITexUpload(CGxTex* texId);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user