Revert "wire vulkan init + gdraw fixes"

This reverts commit 4477781b25d24fa0eba379e745e96b16ad90afbb
This commit is contained in:
kit rae
2026-03-06 02:14:45 +00:00
committed by Kitrae
parent c9d82193df
commit 4cabaad004
3 changed files with 217 additions and 229 deletions

View File

@@ -1,230 +1,217 @@
#pragma once
// ============================================================================
// 4J_Render.h — Vulkan Backend
// Originally wrapped D3D11; now wraps Vulkan via C4JRender implementation.
// ============================================================================
class ImageFileBuffer {
class ImageFileBuffer
{
public:
enum EImageType { e_typePNG, e_typeJPG };
enum EImageType
{
e_typePNG,
e_typeJPG
};
EImageType m_type;
void *m_pBuffer;
int m_bufferSize;
EImageType m_type;
void* m_pBuffer;
int m_bufferSize;
int GetType() { return m_type; }
void *GetBufferPointer() { return m_pBuffer; }
int GetBufferSize() { return m_bufferSize; }
void Release() {
free(m_pBuffer);
m_pBuffer = NULL;
}
bool Allocated() { return m_pBuffer != NULL; }
int GetType() { return m_type; }
void *GetBufferPointer() { return m_pBuffer; }
int GetBufferSize() { return m_bufferSize; }
void Release() { free(m_pBuffer); m_pBuffer = NULL; }
bool Allocated() { return m_pBuffer != NULL; }
};
typedef struct {
int Width;
int Height;
} D3DXIMAGE_INFO;
typedef struct
{
int Width;
int Height;
}D3DXIMAGE_INFO;
typedef struct _XSOCIAL_PREVIEWIMAGE {
BYTE *pBytes;
DWORD Pitch;
DWORD Width;
DWORD Height;
BYTE *pBytes;
DWORD Pitch;
DWORD Width;
DWORD Height;
// D3DFORMAT Format;
} XSOCIAL_PREVIEWIMAGE, *PXSOCIAL_PREVIEWIMAGE;
// Opaque rect for Clear() — maps to scissor rect
typedef struct {
LONG left;
LONG top;
LONG right;
LONG bottom;
} C4JRect;
class C4JRender {
class C4JRender
{
public:
void Tick();
void UpdateGamma(unsigned short usGamma);
void Tick();
void UpdateGamma(unsigned short usGamma);
// Matrix stack
void MatrixMode(int type);
void MatrixSetIdentity();
void MatrixTranslate(float x, float y, float z);
void MatrixRotate(float angle, float x, float y, float z);
void MatrixScale(float x, float y, float z);
void MatrixPerspective(float fovy, float aspect, float zNear, float zFar);
void MatrixOrthogonal(float left, float right, float bottom, float top,
float zNear, float zFar);
void MatrixPop();
void MatrixPush();
void MatrixMult(float *mat);
const float *MatrixGet(int type);
void Set_matrixDirty();
// Matrix stack
void MatrixMode(int type);
void MatrixSetIdentity();
void MatrixTranslate(float x,float y,float z);
void MatrixRotate(float angle, float x, float y, float z);
void MatrixScale(float x, float y, float z);
void MatrixPerspective(float fovy, float aspect, float zNear, float zFar);
void MatrixOrthogonal(float left,float right,float bottom,float top,float zNear,float zFar);
void MatrixPop();
void MatrixPush();
void MatrixMult(float *mat);
const float *MatrixGet(int type);
void Set_matrixDirty();
// Core
void Initialise(HWND hWnd, int width, int height);
void InitialiseContext();
void StartFrame();
void DoScreenGrabOnNextPresent();
void Present();
void Clear(int flags, C4JRect *pRect = NULL);
void SetClearColour(const float colourRGBA[4]);
bool IsWidescreen();
bool IsHiDef();
void CaptureThumbnail(ImageFileBuffer *pngOut);
void CaptureScreen(ImageFileBuffer *jpgOut, XSOCIAL_PREVIEWIMAGE *previewOut);
void BeginConditionalSurvey(int identifier);
void EndConditionalSurvey();
void BeginConditionalRendering(int identifier);
void EndConditionalRendering();
// Core
void Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain);
void InitialiseContext();
void StartFrame();
void DoScreenGrabOnNextPresent();
void Present();
void Clear(int flags, D3D11_RECT *pRect = NULL);
void SetClearColour(const float colourRGBA[4]);
bool IsWidescreen();
bool IsHiDef();
void CaptureThumbnail(ImageFileBuffer *pngOut);
void CaptureScreen(ImageFileBuffer *jpgOut, XSOCIAL_PREVIEWIMAGE *previewOut);
void BeginConditionalSurvey(int identifier);
void EndConditionalSurvey();
void BeginConditionalRendering(int identifier);
void EndConditionalRendering();
// Vertex data handling
typedef enum {
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, // Position 3 x float, texture 2 x float,
// colour 4 x byte, normal 4 x byte,
// padding 1 DWORD
VERTEX_TYPE_COMPRESSED, // Compressed format
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT, // as above with lighting applied
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, // as above with tex gen
VERTEX_TYPE_COUNT
} eVertexType;
// Vertex data handling
typedef enum
{
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, // Position 3 x float, texture 2 x float, colour 4 x byte, normal 4 x byte, padding 1 DWORD
VERTEX_TYPE_COMPRESSED, // Compressed format - see comment at top of VS_PS3_TS2_CS1.hlsl for description of layout
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT, // as VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 with lighting applied,
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, // as VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 with tex gen
VERTEX_TYPE_COUNT
} eVertexType;
// Pixel shader
typedef enum {
PIXEL_SHADER_TYPE_STANDARD,
PIXEL_SHADER_TYPE_PROJECTION,
PIXEL_SHADER_TYPE_FORCELOD,
PIXEL_SHADER_COUNT
} ePixelShaderType;
// Pixel shader
typedef enum
{
PIXEL_SHADER_TYPE_STANDARD,
PIXEL_SHADER_TYPE_PROJECTION,
PIXEL_SHADER_TYPE_FORCELOD,
PIXEL_SHADER_COUNT
} ePixelShaderType;
typedef enum {
VIEWPORT_TYPE_FULLSCREEN,
VIEWPORT_TYPE_SPLIT_TOP,
VIEWPORT_TYPE_SPLIT_BOTTOM,
VIEWPORT_TYPE_SPLIT_LEFT,
VIEWPORT_TYPE_SPLIT_RIGHT,
VIEWPORT_TYPE_QUADRANT_TOP_LEFT,
VIEWPORT_TYPE_QUADRANT_TOP_RIGHT,
VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT,
VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT,
} eViewportType;
typedef enum
{
VIEWPORT_TYPE_FULLSCREEN,
VIEWPORT_TYPE_SPLIT_TOP,
VIEWPORT_TYPE_SPLIT_BOTTOM,
VIEWPORT_TYPE_SPLIT_LEFT,
VIEWPORT_TYPE_SPLIT_RIGHT,
VIEWPORT_TYPE_QUADRANT_TOP_LEFT,
VIEWPORT_TYPE_QUADRANT_TOP_RIGHT,
VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT,
VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT,
} eViewportType;
typedef enum {
PRIMITIVE_TYPE_TRIANGLE_LIST,
PRIMITIVE_TYPE_TRIANGLE_STRIP,
PRIMITIVE_TYPE_TRIANGLE_FAN,
PRIMITIVE_TYPE_QUAD_LIST,
PRIMITIVE_TYPE_LINE_LIST,
PRIMITIVE_TYPE_LINE_STRIP,
PRIMITIVE_TYPE_COUNT
} ePrimitiveType;
typedef enum
{
PRIMITIVE_TYPE_TRIANGLE_LIST,
PRIMITIVE_TYPE_TRIANGLE_STRIP,
PRIMITIVE_TYPE_TRIANGLE_FAN,
PRIMITIVE_TYPE_QUAD_LIST,
PRIMITIVE_TYPE_LINE_LIST,
PRIMITIVE_TYPE_LINE_STRIP,
PRIMITIVE_TYPE_COUNT
} ePrimitiveType;
void DrawVertices(ePrimitiveType PrimitiveType, int count, void *dataIn,
eVertexType vType, C4JRender::ePixelShaderType psType);
// DrawVertexBuffer uses an opaque handle now (was ID3D11Buffer*)
void DrawVertexBuffer(ePrimitiveType PrimitiveType, int count, void *buffer,
C4JRender::eVertexType vType,
C4JRender::ePixelShaderType psType);
void DrawVertices(ePrimitiveType PrimitiveType, int count, void *dataIn, eVertexType vType, C4JRender::ePixelShaderType psType);
void DrawVertexBuffer(ePrimitiveType PrimitiveType, int count, ID3D11Buffer *buffer, C4JRender::eVertexType vType, C4JRender::ePixelShaderType psType);
// Command buffers
void CBuffLockStaticCreations();
int CBuffCreate(int count);
void CBuffDelete(int first, int count);
void CBuffStart(int index, bool full = false);
void CBuffClear(int index);
int CBuffSize(int index);
void CBuffEnd();
bool CBuffCall(int index, bool full = true);
void CBuffTick();
void CBuffDeferredModeStart();
void CBuffDeferredModeEnd();
// Command buffers
void CBuffLockStaticCreations();
int CBuffCreate(int count);
void CBuffDelete(int first, int count);
void CBuffStart(int index, bool full = false);
void CBuffClear(int index);
int CBuffSize(int index);
void CBuffEnd();
bool CBuffCall(int index, bool full = true);
void CBuffTick();
void CBuffDeferredModeStart();
void CBuffDeferredModeEnd();
typedef enum {
TEXTURE_FORMAT_RxGyBzAw, // Normal 32-bit RGBA texture, 8 bits per component
MAX_TEXTURE_FORMATS
} eTextureFormat;
typedef enum
{
TEXTURE_FORMAT_RxGyBzAw, // Normal 32-bit RGBA texture, 8 bits per component
/* Don't think these are all directly available on D3D 11 - leaving for now
TEXTURE_FORMAT_R0G0B0Ax, // One 8-bit component mapped to alpha channel, R=G=B=0
TEXTURE_FORMAT_R1G1B1Ax, // One 8-bit component mapped to alpha channel, R=G=B=1
TEXTURE_FORMAT_RxGxBxAx, // One 8-bit component mapped to all channels
*/
MAX_TEXTURE_FORMATS
} eTextureFormat;
// Textures
int TextureCreate();
void TextureFree(int idx);
void TextureBind(int idx);
void TextureBindVertex(int idx);
void TextureSetTextureLevels(int levels);
int TextureGetTextureLevels();
void TextureData(int width, int height, void *data, int level,
eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw);
void TextureDataUpdate(int xoffset, int yoffset, int width, int height,
void *data, int level);
void TextureSetParam(int param, int value);
void TextureDynamicUpdateStart();
void TextureDynamicUpdateEnd();
HRESULT LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo,
int **ppDataOut);
HRESULT LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo,
int **ppDataOut);
HRESULT SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo,
int *ppDataOut);
HRESULT SaveTextureDataToMemory(void *pOutput, int outputCapacity,
int *outputLength, int width, int height,
int *ppDataIn);
void TextureGetStats();
// Returns an opaque texture handle (was ID3D11ShaderResourceView*)
void *TextureGetTexture(int idx);
// Textures
int TextureCreate();
void TextureFree(int idx);
void TextureBind(int idx);
void TextureBindVertex(int idx);
void TextureSetTextureLevels(int levels);
int TextureGetTextureLevels();
void TextureData(int width, int height, void *data, int level, eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw);
void TextureDataUpdate(int xoffset, int yoffset, int width, int height, void *data, int level);
void TextureSetParam(int param, int value);
void TextureDynamicUpdateStart();
void TextureDynamicUpdateEnd();
HRESULT LoadTextureData(const char *szFilename,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut);
HRESULT LoadTextureData(BYTE *pbData, DWORD dwBytes,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut);
HRESULT SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut);
HRESULT SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn);
void TextureGetStats();
ID3D11ShaderResourceView *TextureGetTexture(int idx);
// State control
void StateSetColour(float r, float g, float b, float a);
void StateSetDepthMask(bool enable);
void StateSetBlendEnable(bool enable);
void StateSetBlendFunc(int src, int dst);
void StateSetBlendFactor(unsigned int colour);
void StateSetAlphaFunc(int func, float param);
void StateSetDepthFunc(int func);
void StateSetFaceCull(bool enable);
void StateSetFaceCullCW(bool enable);
void StateSetLineWidth(float width);
void StateSetWriteEnable(bool red, bool green, bool blue, bool alpha);
void StateSetDepthTestEnable(bool enable);
void StateSetAlphaTestEnable(bool enable);
void StateSetDepthSlopeAndBias(float slope, float bias);
void StateSetFogEnable(bool enable);
void StateSetFogMode(int mode);
void StateSetFogNearDistance(float dist);
void StateSetFogFarDistance(float dist);
void StateSetFogDensity(float density);
void StateSetFogColour(float red, float green, float blue);
void StateSetLightingEnable(bool enable);
void StateSetVertexTextureUV(float u, float v);
void StateSetLightColour(int light, float red, float green, float blue);
void StateSetLightAmbientColour(float red, float green, float blue);
void StateSetLightDirection(int light, float x, float y, float z);
void StateSetLightEnable(int light, bool enable);
void StateSetViewport(eViewportType viewportType);
void StateSetEnableViewportClipPlanes(bool enable);
void StateSetTexGenCol(int col, float x, float y, float z, float w,
bool eyeSpace);
void StateSetStencil(int Function, uint8_t stencil_ref,
uint8_t stencil_func_mask, uint8_t stencil_write_mask);
void StateSetForceLOD(int LOD);
// State control
void StateSetColour(float r, float g, float b, float a);
void StateSetDepthMask(bool enable);
void StateSetBlendEnable(bool enable);
void StateSetBlendFunc(int src, int dst);
void StateSetBlendFactor(unsigned int colour);
void StateSetAlphaFunc(int func, float param);
void StateSetDepthFunc(int func);
void StateSetFaceCull(bool enable);
void StateSetFaceCullCW(bool enable);
void StateSetLineWidth(float width);
void StateSetWriteEnable(bool red, bool green, bool blue, bool alpha);
void StateSetDepthTestEnable(bool enable);
void StateSetAlphaTestEnable(bool enable);
void StateSetDepthSlopeAndBias(float slope, float bias);
void StateSetFogEnable(bool enable);
void StateSetFogMode(int mode);
void StateSetFogNearDistance(float dist);
void StateSetFogFarDistance(float dist);
void StateSetFogDensity(float density);
void StateSetFogColour(float red, float green, float blue);
void StateSetLightingEnable(bool enable);
void StateSetVertexTextureUV( float u, float v);
void StateSetLightColour(int light, float red, float green, float blue);
void StateSetLightAmbientColour(float red, float green, float blue);
void StateSetLightDirection(int light, float x, float y, float z);
void StateSetLightEnable(int light, bool enable);
void StateSetViewport(eViewportType viewportType);
void StateSetEnableViewportClipPlanes(bool enable);
void StateSetTexGenCol(int col, float x, float y, float z, float w, bool eyeSpace);
void StateSetStencil(int Function, uint8_t stencil_ref, uint8_t stencil_func_mask, uint8_t stencil_write_mask);
void StateSetForceLOD(int LOD);
// Event tracking
void BeginEvent(LPCWSTR eventName);
void EndEvent();
// Event tracking
void BeginEvent(LPCWSTR eventName);
void EndEvent();
// PLM event handling
void Suspend();
bool Suspended();
void Resume();
// PLM event handling
void Suspend();
bool Suspended();
void Resume();
};
const int GL_MODELVIEW_MATRIX = 0;
const int GL_PROJECTION_MATRIX = 1;
const int GL_MODELVIEW = 0;
const int GL_PROJECTION = 1;
const int GL_TEXTURE = 2;
// Tex gen constants
// These things required for tex gen
const int GL_S = 0;
const int GL_T = 1;
const int GL_R = 2;
@@ -241,7 +228,8 @@ const int GL_EYE_LINEAR = 1;
const int GL_OBJECT_PLANE = 0;
const int GL_EYE_PLANE = 1;
// glEnable/glDisable tokens
// These things are used by glEnable/glDisable so must be different and non-zero (zero is used by things we haven't assigned yet)
const int GL_TEXTURE_2D = 1;
const int GL_BLEND = 2;
const int GL_CULL_FACE = 3;
@@ -258,25 +246,23 @@ const int CLEAR_COLOUR_FLAG = 2;
const int GL_DEPTH_BUFFER_BIT = CLEAR_DEPTH_FLAG;
const int GL_COLOR_BUFFER_BIT = CLEAR_COLOUR_FLAG;
// Blend factors — hardcoded values matching the original D3D11 enum values
const int GL_SRC_ALPHA = 5; // D3D11_BLEND_SRC_ALPHA
const int GL_ONE_MINUS_SRC_ALPHA = 6; // D3D11_BLEND_INV_SRC_ALPHA
const int GL_ONE = 2; // D3D11_BLEND_ONE
const int GL_ZERO = 1; // D3D11_BLEND_ZERO
const int GL_DST_ALPHA = 7; // D3D11_BLEND_DEST_ALPHA
const int GL_SRC_COLOR = 3; // D3D11_BLEND_SRC_COLOR
const int GL_DST_COLOR = 9; // D3D11_BLEND_DEST_COLOR
const int GL_ONE_MINUS_DST_COLOR = 10; // D3D11_BLEND_INV_DEST_COLOR
const int GL_ONE_MINUS_SRC_COLOR = 4; // D3D11_BLEND_INV_SRC_COLOR
const int GL_CONSTANT_ALPHA = 17; // D3D11_BLEND_BLEND_FACTOR
const int GL_ONE_MINUS_CONSTANT_ALPHA = 18; // D3D11_BLEND_INV_BLEND_FACTOR
const int GL_SRC_ALPHA = D3D11_BLEND_SRC_ALPHA;
const int GL_ONE_MINUS_SRC_ALPHA = D3D11_BLEND_INV_SRC_ALPHA;
const int GL_ONE = D3D11_BLEND_ONE;
const int GL_ZERO = D3D11_BLEND_ZERO;
const int GL_DST_ALPHA = D3D11_BLEND_DEST_ALPHA;
const int GL_SRC_COLOR = D3D11_BLEND_SRC_COLOR;
const int GL_DST_COLOR = D3D11_BLEND_DEST_COLOR;
const int GL_ONE_MINUS_DST_COLOR = D3D11_BLEND_INV_DEST_COLOR;
const int GL_ONE_MINUS_SRC_COLOR = D3D11_BLEND_INV_SRC_COLOR;
const int GL_CONSTANT_ALPHA = D3D11_BLEND_BLEND_FACTOR;
const int GL_ONE_MINUS_CONSTANT_ALPHA = D3D11_BLEND_INV_BLEND_FACTOR;
// Comparison functions — matching D3D11 enum values
const int GL_GREATER = 5; // D3D11_COMPARISON_GREATER
const int GL_EQUAL = 3; // D3D11_COMPARISON_EQUAL
const int GL_LEQUAL = 4; // D3D11_COMPARISON_LESS_EQUAL
const int GL_GEQUAL = 7; // D3D11_COMPARISON_GREATER_EQUAL
const int GL_ALWAYS = 8; // D3D11_COMPARISON_ALWAYS
const int GL_GREATER = D3D11_COMPARISON_GREATER;
const int GL_EQUAL = D3D11_COMPARISON_EQUAL;
const int GL_LEQUAL = D3D11_COMPARISON_LESS_EQUAL;
const int GL_GEQUAL = D3D11_COMPARISON_GREATER_EQUAL;
const int GL_ALWAYS = D3D11_COMPARISON_ALWAYS;
const int GL_TEXTURE_MIN_FILTER = 1;
const int GL_TEXTURE_MAG_FILTER = 2;
@@ -286,7 +272,7 @@ const int GL_TEXTURE_WRAP_T = 4;
const int GL_NEAREST = 0;
const int GL_LINEAR = 1;
const int GL_EXP = 2;
const int GL_NEAREST_MIPMAP_LINEAR = 0;
const int GL_NEAREST_MIPMAP_LINEAR = 0; // TODO - mipmapping bit of this
const int GL_CLAMP = 0;
const int GL_REPEAT = 1;
@@ -312,3 +298,5 @@ const int GL_TRIANGLE_STRIP = C4JRender::PRIMITIVE_TYPE_TRIANGLE_STRIP;
// Singleton
extern C4JRender RenderManager;

View File

@@ -502,7 +502,7 @@ static GDrawTexture * RADLINK gdraw_MakeTextureEnd(GDraw_MakeTexture_ProcessingI
}
// actually create texture
D3D1X_(TEXTURE2D_DESC) desc = { static_cast<U32>(w), static_cast<U32>(h), static_cast<U32>(nmips), 1, static_cast<DXGI_FORMAT>(p->i3), { 1, 0 },
D3D1X_(TEXTURE2D_DESC) desc = { w, h, nmips, 1, (DXGI_FORMAT) p->i3, { 1, 0 },
(p->i2 & GDRAW_MAKETEXTURE_FLAGS_updatable) ? D3D1X_(USAGE_DEFAULT) : D3D1X_(USAGE_IMMUTABLE),
D3D1X_(BIND_SHADER_RESOURCE), 0, 0 };
@@ -541,7 +541,7 @@ static rrbool RADLINK gdraw_UpdateTextureBegin(GDrawTexture *t, void *unique_id,
static void RADLINK gdraw_UpdateTextureRect(GDrawTexture *t, void * /*unique_id*/, S32 x, S32 y, S32 stride, S32 w, S32 h, U8 *samples, gdraw_texture_format /*format*/)
{
GDrawHandle *s = (GDrawHandle *) t;
D3D1X_(BOX) box = { static_cast<U32>(x), static_cast<U32>(y), 0U, static_cast<U32>(x + w), static_cast<U32>(y + h), 1U };
D3D1X_(BOX) box = { x, y, 0, x+w, y+h, 1 };
gdraw->d3d_context->UpdateSubresource(s->handle.tex.d3d, 0, &box, samples, stride, 0);
}
@@ -586,8 +586,8 @@ static void RADLINK gdraw_SetAntialiasTexture(S32 width, U8 *rgba)
safe_release(gdraw->aa_tex_view);
safe_release(gdraw->aa_tex);
D3D1X_(TEXTURE2D_DESC) desc = { static_cast<U32>(width), 1U, 1U, 1U, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_SHADER_RESOURCE), 0U, 0U };
D3D1X_(SUBRESOURCE_DATA) data = { rgba, static_cast<U32>(width) * 4U, 0U };
D3D1X_(TEXTURE2D_DESC) desc = { width, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_SHADER_RESOURCE), 0, 0 };
D3D1X_(SUBRESOURCE_DATA) data = { rgba, width*4, 0 };
hr = gdraw->d3d_device->CreateTexture2D(&desc, &data, &gdraw->aa_tex);
if (FAILED(hr)) {
@@ -646,10 +646,10 @@ static GDrawVertexBuffer * RADLINK gdraw_MakeVertexBufferEnd(GDraw_MakeVertexBuf
GDrawHandle *vb = (GDrawHandle *) p->p0;
HRESULT hr;
D3D1X_(BUFFER_DESC) vbdesc = { static_cast<U32>(p->vertex_data_length), D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_VERTEX_BUFFER), 0U, 0U };
D3D1X_(BUFFER_DESC) vbdesc = { p->vertex_data_length, D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_VERTEX_BUFFER), 0, 0 };
D3D1X_(SUBRESOURCE_DATA) vbdata = { p->vertex_data, 0, 0 };
D3D1X_(BUFFER_DESC) ibdesc = { static_cast<U32>(p->index_data_length), D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_INDEX_BUFFER), 0U, 0U };
D3D1X_(BUFFER_DESC) ibdesc = { p->index_data_length, D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_INDEX_BUFFER), 0, 0 };
D3D1X_(SUBRESOURCE_DATA) ibdata = { p->index_data, 0, 0 };
hr = gdraw->d3d_device->CreateBuffer(&vbdesc, &vbdata, &vb->handle.vbuf.verts);
@@ -722,8 +722,8 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats)
return t;
}
D3D1X_(TEXTURE2D_DESC) desc = { static_cast<U32>(gdraw->frametex_width), static_cast<U32>(gdraw->frametex_height), 1U, 1U, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 },
D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_SHADER_RESOURCE) | D3D1X_(BIND_RENDER_TARGET), 0U, 0U };
D3D1X_(TEXTURE2D_DESC) desc = { gdraw->frametex_width, gdraw->frametex_height, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 },
D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_SHADER_RESOURCE) | D3D1X_(BIND_RENDER_TARGET), 0, 0 };
t->handle.tex.d3d = NULL;
t->handle.tex.d3d_view = NULL;
@@ -765,8 +765,8 @@ static ID3D1X(DepthStencilView) *get_rendertarget_depthbuffer(GDrawStats *stats)
char *failed_call;
assert(!gdraw->rt_depth_buffer);
D3D1X_(TEXTURE2D_DESC) desc = { static_cast<U32>(gdraw->frametex_width), static_cast<U32>(gdraw->frametex_height), 1U, 1U, DXGI_FORMAT_D24_UNORM_S8_UINT, { 1, 0 },
D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_DEPTH_STENCIL), 0U, 0U };
D3D1X_(TEXTURE2D_DESC) desc = { gdraw->frametex_width, gdraw->frametex_height, 1, 1, DXGI_FORMAT_D24_UNORM_S8_UINT, { 1, 0 },
D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_DEPTH_STENCIL), 0, 0 };
HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, NULL, &gdraw->rt_depth_buffer);
failed_call = "CreateTexture2D";
@@ -2399,8 +2399,8 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file,
mipmaps = texture->mipmaps;
blk = 1;
D3D1X_(TEXTURE2D_DESC) desc = { static_cast<U32>(width), static_cast<U32>(height), static_cast<U32>(mipmaps), 1U, DXGI_FORMAT_UNKNOWN, { 1, 0 },
D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_SHADER_RESOURCE), 0U, 0U };
D3D1X_(TEXTURE2D_DESC) desc = { width, height, mipmaps, 1, DXGI_FORMAT_UNKNOWN, { 1, 0 },
D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_SHADER_RESOURCE), 0, 0 };
switch (texture->format) {
case IFT_FORMAT_rgba_8888 : size= 4; d3dfmt = DXGI_FORMAT_R8G8B8A8_UNORM; break;

View File

@@ -858,7 +858,7 @@ HRESULT InitDevice()
vp.TopLeftY = 0;
g_pImmediateContext->RSSetViewports( 1, &vp );
RenderManager.Initialise(g_hWnd, width, height);
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
return S_OK;
}
@@ -1029,7 +1029,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
#endif
app.loadMediaArchive();
RenderManager.Initialise(g_hWnd, g_iScreenWidth, g_iScreenHeight);
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
app.loadStringTable();
ui.init(g_pd3dDevice,g_pImmediateContext,g_pRenderTargetView,g_pDepthStencilView,g_iScreenWidth,g_iScreenHeight);
@@ -1747,4 +1747,4 @@ void MemPixStuff()
PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages");
}
#endif
#endif