Skip to content

Commit

Permalink
Merge pull request #15 from OpenXRay/xd_dev
Browse files Browse the repository at this point in the history
Big merge directly from xd_dev
  • Loading branch information
q4a committed Oct 13, 2018
2 parents 29348f1 + 43ef63a commit a8d2bea
Show file tree
Hide file tree
Showing 57 changed files with 870 additions and 673 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ X-Ray Engine 1.6 expansion [![Codacy Badge](https://api.codacy.com/project/badge

### Build Status:

|Platform|Build Status|
|--------|------|
| Linux (GCC)(Release)(x64/x86) |[![Build Status](https://api.travis-ci.org/q4a/xray-16.svg?branch=linux)](https://travis-ci.org/q4a/xray-16)|
| Windows (MSVC)(Debug/Mixed/Release)(x64/x86) |[![Build status](https://ci.appveyor.com/api/projects/status/beb4c2xtyru4galx/branch/linux?svg=true)](https://ci.appveyor.com/project/q4a/xray-16)|
|Platform|Build status: [xd_dev branch](https://github.com/OpenXRay/xray-16)|Build status: [linux branch](https://github.com/q4a/xray-16)|
|--------|--------|--------|
| Linux (GCC)(Release)(x64/x86) |[![Build Status](https://api.travis-ci.org/OpenXRay/xray-16.svg?branch=xd_dev)](https://travis-ci.org/OpenXRay/xray-16)|[![Build Status](https://api.travis-ci.org/q4a/xray-16.svg?branch=linux)](https://travis-ci.org/q4a/xray-16)|
| Windows (MSVC)(Debug/Mixed/Release)(x64/x86) |[![Build status](https://ci.appveyor.com/api/projects/status/16mp39v0d7fts6yf?svg=true)](https://ci.appveyor.com/project/OpenXRay/xray-16)|[![Build status](https://ci.appveyor.com/api/projects/status/beb4c2xtyru4galx/branch/linux?svg=true)](https://ci.appveyor.com/project/q4a/xray-16)|

This repository contains X-Ray Engine sources based on version 1.6.02.
The original engine is used in S.T.A.L.K.E.R. Call of Pripyat game released by GSC Game World.
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ deploy:
release: OpenXRay (build $(appveyor_build_version))
description: $(APPVEYOR_REPO_COMMIT_MESSAGE)
auth_token:
secure: EwMP7ob9Q7cE1EvW72ybDSYjbD44IQRDFhbCQcdOuBSSz9PbO/Pq2ZUNuMqPuvsV
secure: kGVniXDR926BfVcA97y25BzALbijvgboBsozZzY9yc8RPz15Q4YG474h7vl14/J1
artifact:
OpenXRay.Dx86.7z, OpenXRay.Dx64.7z, OpenXRay.Mx86.7z, OpenXRay.Mx64.7z, OpenXRay.Rx86.7z, OpenXRay.Rx64.7z,
Symbols.Dx86.7z, Symbols.Dx64.7z, Symbols.Mx86.7z, Symbols.Mx64.7z, Symbols.Rx86.7z, Symbols.Rx64.7z
draft: true
force_update: true
force_update: true
24 changes: 24 additions & 0 deletions res/gamedata/shaders/r3/editor.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "common.h"

struct vf
{
float4 C : COLOR0;
float4 P : POSITION;
};

struct v2p
{
float4 C : COLOR0;
float4 P : SV_Position;
};

uniform float4 tfactor;
v2p main (vf i)
{
v2p o;

o.P = mul (m_WVP, i.P); // xform, input in world coords
o.C = tfactor*unpack_D3DCOLOR(i.C);

return o;
}
4 changes: 2 additions & 2 deletions src/Layers/xrRender/Blender_Particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
C.r_dx10Texture("s_base", C.L_textures[0]);
u32 hSampler = C.r_dx10Sampler("smp_base");
if (oClamp.value && (hSampler != (u32)-1))
C.i_dx10Address(hSampler, D3DTADDRESS_CLAMP);
C.i_Address(hSampler, D3DTADDRESS_CLAMP);
// Igor: soft particles
// C.r_Sampler ("s_position", "$user$position");
C.r_dx10Texture("s_position", "$user$position");
Expand Down Expand Up @@ -243,7 +243,7 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
C.r_dx10Texture("s_base", C.L_textures[0]);
u32 hSampler = C.r_dx10Sampler("smp_base");
if (oClamp.value && (hSampler != (u32)-1))
C.i_dx10Address(hSampler, D3DTADDRESS_CLAMP);
C.i_Address(hSampler, D3DTADDRESS_CLAMP);
// Igor: soft particles
//C.r_Sampler ("s_position", "$user$position");
C.r_dx10Texture("s_position", "$user$position");
Expand Down
6 changes: 5 additions & 1 deletion src/Layers/xrRender/Blender_Recorder_R2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ void CBlender_Compile::i_Projective(u32 s, bool b)
else
RS.SetTSS(s, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
}
#endif // USE_DX10

void CBlender_Compile::i_Address(u32 s, u32 address)
{
RS.SetSAMP(s, D3DSAMP_ADDRESSU, address);
Expand All @@ -118,6 +120,8 @@ void CBlender_Compile::i_Filter(u32 s, u32 _min, u32 _mip, u32 _mag)
i_Filter_Mip(s, _mip);
i_Filter_Mag(s, _mag);
}

#if !defined(USE_DX10) && !defined(USE_DX11)
u32 CBlender_Compile::r_Sampler(
LPCSTR _name, LPCSTR texture, bool b_ps1x_ProjectiveDivide, u32 address, u32 fmin, u32 fmip, u32 fmag)
{
Expand Down Expand Up @@ -185,4 +189,4 @@ void CBlender_Compile::r_End()
#endif
SH->passes.push_back(RImplementation.Resources->_CreatePass(dest));
}
#endif // USE_DX10
#endif // USE_DX10
4 changes: 2 additions & 2 deletions src/Layers/xrRender/Blender_Screen_SET.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void CBlender_Screen_SET::Compile(CBlender_Compile& C)
C.r_dx10Texture("s_base", C.L_textures[0]);
int iSmp = C.r_dx10Sampler("smp_base");
if (oClamp.value)
C.i_dx10Address(iSmp, D3DTADDRESS_CLAMP);
C.i_Address(iSmp, D3DTADDRESS_CLAMP);
}
else
{
Expand Down Expand Up @@ -165,7 +165,7 @@ void CBlender_Screen_SET::Compile(CBlender_Compile& C)
C.r_dx10Texture("s_base", C.L_textures[0]);
int iSmp = C.r_dx10Sampler("smp_base");
if ((oClamp.value) && (iSmp != u32(-1)))
C.i_dx10Address(iSmp, D3DTADDRESS_CLAMP);
C.i_Address(iSmp, D3DTADDRESS_CLAMP);
}

C.PassSET_ZB(oZTest.value, oZWrite.value);
Expand Down
18 changes: 9 additions & 9 deletions src/Layers/xrRender/FVisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ void Fvisual::Load(const char* N, IReader* data, u32 dwFlags)
p_rm_Indices->AddRef();
#endif
#endif
#if (RENDER == R_R2) || (RENDER == R_R3) || (RENDER == R_R4) || (RENDER == R_GL)
// check for fast-vertices
#if RENDER == R_R1
if (data->find_chunk(OGF_FASTPATH) && ps_r1_force_geomx)
#else
if (data->find_chunk(OGF_FASTPATH))
#endif
{
destructor<IReader> geomdef(data->open_chunk(OGF_FASTPATH));
destructor<IReader> def(geomdef().open_chunk(OGF_GCONTAINER));
Expand Down Expand Up @@ -97,7 +100,6 @@ void Fvisual::Load(const char* N, IReader* data, u32 dwFlags)
// geom
m_fast->rm_geom.create(fmt, m_fast->p_rm_Vertices, m_fast->p_rm_Indices);
}
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)
}

// read vertices
Expand Down Expand Up @@ -222,8 +224,11 @@ void Fvisual::Load(const char* N, IReader* data, u32 dwFlags)

void Fvisual::Render(float)
{
#if (RENDER == R_R2) || (RENDER == R_R3) || (RENDER == R_R4) || (RENDER==R_GL)
if (m_fast && RImplementation.phase == CRender::PHASE_SMAP && !RCache.is_TessEnabled())
#if RENDER == R_R1
if (m_fast && ps_r1_force_geomx)
#else
if (m_fast && (ps_r1_force_geomx || RImplementation.phase == CRender::PHASE_SMAP && !RCache.is_TessEnabled()))
#endif
{
RCache.set_Geometry(m_fast->rm_geom);
RCache.Render(D3DPT_TRIANGLELIST, m_fast->vBase, 0, m_fast->vCount, m_fast->iBase, m_fast->dwPrimitives);
Expand All @@ -235,11 +240,6 @@ void Fvisual::Render(float)
RCache.Render(D3DPT_TRIANGLELIST, vBase, 0, vCount, iBase, dwPrimitives);
RCache.stat.r.s_static.add(vCount);
}
#else // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)
RCache.set_Geometry(rm_geom);
RCache.Render(D3DPT_TRIANGLELIST, vBase, 0, vCount, iBase, dwPrimitives);
RCache.stat.r.s_static.add(vCount);
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)
}

#define PCOPY(a) a = pFrom->a
Expand Down
71 changes: 24 additions & 47 deletions src/Layers/xrRender/HW.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,20 @@ class CHW
BOOL support(D3DFORMAT fmt, DWORD type, DWORD usage);
#endif // !USE_OGL

#ifdef DEBUG
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
void Validate(void){};
#else // USE_DX10
void Validate(void)
#if defined(DEBUG) && defined(USE_DX9)
void Validate()
{
VERIFY(pDevice);
VERIFY(pD3D);
};
#endif // USE_DX10
#else
void Validate(void){};
void Validate() {}
#endif

// Variables section
// Variables section
public:
CHWCaps Caps;

#if defined(USE_OGL)
CHW* pDevice;
CHW* pContext;
Expand All @@ -63,62 +62,40 @@ class CHW
GLuint pFB;
GLuint pCFB;

CHWCaps Caps;

SDL_Window* m_hWnd;
HDC m_hDC;
SDL_GLContext m_hRC;
#elif defined(USE_DX11)
public:
IDXGIFactory1* m_pFactory = nullptr;
IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent
ID3D11Device* pDevice = nullptr; // combine with DX9 pDevice via typedef
ID3D11DeviceContext* pContext = nullptr; // combine with DX9 pDevice via typedef
IDXGISwapChain* m_pSwapChain = nullptr;
ID3D11RenderTargetView* pBaseRT = nullptr; // combine with DX9 pBaseRT via typedef
ID3D11DepthStencilView* pBaseZB = nullptr;

CHWCaps Caps;
#else // General DirectX
ID3DDevice* pDevice = nullptr; // render device
ID3DRenderTargetView* pBaseRT = nullptr; // base render target
ID3DDepthStencilView* pBaseZB = nullptr; // base depth-stencil buffer

D3D_DRIVER_TYPE m_DriverType;
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
D3D_FEATURE_LEVEL FeatureLevel;
#elif defined(USE_DX10)
public:
#ifndef USE_DX9
IDXGIFactory1* m_pFactory = nullptr;
IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent
ID3D10Device1* pDevice1 = nullptr; // combine with DX9 pDevice via typedef
ID3D10Device* pDevice = nullptr; // combine with DX9 pDevice via typedef
ID3D10Device1* pContext1 = nullptr; // combine with DX9 pDevice via typedef
ID3D10Device* pContext = nullptr; // combine with DX9 pDevice via typedef
IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent
ID3DDeviceContext* pContext = nullptr;
IDXGISwapChain* m_pSwapChain = nullptr;
ID3D10RenderTargetView* pBaseRT = nullptr; // combine with DX9 pBaseRT via typedef
ID3D10DepthStencilView* pBaseZB = nullptr;

CHWCaps Caps;

D3D10_DRIVER_TYPE m_DriverType;
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
D3D_FEATURE_LEVEL FeatureLevel;
#else
private:
#if defined(USE_DX10)
ID3D10Device1* pDevice1 = nullptr;
ID3D10Device1* pContext1 = nullptr;
#endif
#else // USE_DX9
#ifdef DEBUG
IDirect3DStateBlock9* dwDebugSB = nullptr;
#endif
private:
XRay::Module hD3D = nullptr;

public:
IDirect3D9* pD3D = nullptr; // D3D
IDirect3DDevice9* pDevice = nullptr; // render device
IDirect3DSurface9* pBaseRT = nullptr;
IDirect3DSurface9* pBaseZB = nullptr;

CHWCaps Caps;

UINT DevAdapter;
D3DDEVTYPE m_DriverType;
D3DPRESENT_PARAMETERS DevPP;
#endif // USE_DX10
#endif // USE_DX9
#endif // USE_OGL

#if !defined(_MAYA_EXPORT) && !defined(USE_OGL)
stats_manager stats_manager;
Expand All @@ -128,7 +105,7 @@ class CHW
void UpdateViews();
#endif
#if defined(USE_DX10) || defined(USE_DX11)
bool CheckFormatSupport(DXGI_FORMAT format, D3D_FORMAT_SUPPORT feature) const;
bool CheckFormatSupport(DXGI_FORMAT format, UINT feature) const;
DXGI_FORMAT SelectFormat(D3D_FORMAT_SUPPORT feature, const DXGI_FORMAT formats[], size_t count) const;
virtual void OnAppActivate();
virtual void OnAppDeactivate();
Expand Down
7 changes: 2 additions & 5 deletions src/Layers/xrRender/LightTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,8 @@ void CROS_impl::update_smooth(IRenderable* O)

void CROS_impl::calc_sun_value(Fvector& position, IGameObject* _object)
{
#if RENDER == R_R1
light* sun = (light*)RImplementation.L_DB->sun._get();
#else
light* sun = (light*)RImplementation.Lights.sun._get();
#endif

if (MODE & IRender_ObjectSpecific::TRACE_SUN)
{
if (--result_sun < 0)
Expand Down Expand Up @@ -530,7 +527,7 @@ void CROS_impl::prepare_lights(Fvector& position, IRenderable* O)
}

#if RENDER == R_R1
light* sun = (light*)RImplementation.L_DB->sun._get();
light* sun = (light*)RImplementation.Lights.sun._get();

// Sun
float E = sun_smooth * sun->color.intensity();
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/ResourceManager_Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void CResourceManager::DBG_VerifyGeoms()
*/
}

SGeometry* CResourceManager::CreateGeom(D3DVERTEXELEMENT9* decl, IDirect3DVertexBuffer9* vb, IDirect3DIndexBuffer9* ib)
SGeometry* CResourceManager::CreateGeom(D3DVERTEXELEMENT9* decl, ID3DVertexBuffer* vb, ID3DIndexBuffer* ib)
{
R_ASSERT(decl && vb);

Expand All @@ -310,7 +310,7 @@ SGeometry* CResourceManager::CreateGeom(D3DVERTEXELEMENT9* decl, IDirect3DVertex
v_geoms.push_back(Geom);
return Geom;
}
SGeometry* CResourceManager::CreateGeom(u32 FVF, IDirect3DVertexBuffer9* vb, IDirect3DIndexBuffer9* ib)
SGeometry* CResourceManager::CreateGeom(u32 FVF, ID3DVertexBuffer* vb, ID3DIndexBuffer* ib)
{
D3DVERTEXELEMENT9 dcl[MAX_FVF_DECL_SIZE];
CHK_DX(D3DXDeclaratorFromFVF(FVF, dcl));
Expand Down
Loading

0 comments on commit a8d2bea

Please sign in to comment.