1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-01-29 10:38:04 +01:00

fix PS Vita build

This commit is contained in:
XProger 2021-01-26 05:45:56 +03:00
parent 4c5d1e3fc7
commit ae5c04d652
10 changed files with 88 additions and 60 deletions

View File

@ -1006,6 +1006,13 @@ namespace Core {
settings.audio.reverb = false;
#endif
#ifdef _OS_PSV
settings.detail.setFilter (Core::Settings::HIGH);
settings.detail.setLighting (Core::Settings::LOW);
settings.detail.setShadows (Core::Settings::LOW);
settings.detail.setWater (Core::Settings::MEDIUM);
#endif
#ifdef _OS_XBOX
settings.detail.setFilter (Core::Settings::HIGH);
settings.detail.setLighting (Core::Settings::LOW);

View File

@ -58,7 +58,6 @@ namespace GAPI {
ID3D11RenderTargetView *defRTV;
ID3D11DepthStencilView *defDSV;
ID3D11InputLayout *inputLayout;
ID3D11BlendState *BS[2][bmMAX]; // [colorWrite][blendMode] ONLY two colorWrite modes are supported (A and RGBA)
ID3D11RasterizerState *RS[cmMAX]; // [cullMode]
@ -109,6 +108,7 @@ namespace GAPI {
struct Shader {
ID3D11VertexShader *VS;
ID3D11PixelShader *PS;
ID3D11InputLayout *IL;
ID3D11Buffer *CB;
vec4 cbMem[98 + MAX_CONTACTS];
@ -214,7 +214,7 @@ namespace GAPI {
{ "COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // aLight
};
ret = device->CreateInputLayout(vertexDecl, COUNT(vertexDecl), vSrc, vSize, &inputLayout);
ret = device->CreateInputLayout(vertexDecl, COUNT(vertexDecl), vSrc, vSize, &IL);
ASSERT(ret == S_OK);
rebind = true;
@ -229,6 +229,8 @@ namespace GAPI {
}
void deinit() {
SAFE_RELEASE(CB);
SAFE_RELEASE(IL);
SAFE_RELEASE(VS);
SAFE_RELEASE(PS);
}
@ -243,7 +245,7 @@ namespace GAPI {
void validate() {
if (rebind) {
deviceContext->IASetInputLayout(inputLayout);
deviceContext->IASetInputLayout(IL);
deviceContext->VSSetShader(VS, NULL, 0);
deviceContext->PSSetShader(PS, NULL, 0);
rebind = false;

View File

@ -472,7 +472,6 @@ namespace GAPI {
bool rebind;
void init(Pass pass, int type, int *def, int defCount) {
LOG("init shader %d %d ", int(pass), int(type));
memset(pso, 0, sizeof(pso));
outputFmt = SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4;
@ -536,6 +535,7 @@ namespace GAPI {
case 1 : vSrc = SHADER ( filter_downsample, v ); fSrc = SHADER ( filter_downsample, f ); break;
case 3 : vSrc = SHADER ( filter_grayscale, v ); fSrc = SHADER ( filter_grayscale, f ); break;
case 4 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break;
case 5 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break;
default : ASSERT(false);
}
break;
@ -545,8 +545,6 @@ namespace GAPI {
default : ASSERT(false); LOG("! wrong pass id\n"); return;
}
LOG(" %s", vSrc != NULL ? "true" : "false");
#undef SHADER_A
#undef SHADER_U
#undef SHADER_AU
@ -602,8 +600,6 @@ namespace GAPI {
}
colorMask = blendMode = -1;
LOG("done\n");
}
void deinit() {
@ -770,9 +766,10 @@ namespace GAPI {
bool mipmaps = (opt & OPT_MIPMAPS) != 0;
bool isCube = (opt & OPT_CUBEMAP) != 0;
bool isTarget = (opt & OPT_TARGET) != 0;
bool isDynamic = (opt & OPT_DYNAMIC) != 0;
bool isShadow = fmt == FMT_SHADOW;
bool isTiled = isTarget;
bool isSwizzled = !isTiled && filter;
bool isSwizzled = !isDynamic && !isTiled && filter;
FormatDesc desc = formats[fmt];
@ -1127,7 +1124,6 @@ namespace GAPI {
support.colorHalf = true;
support.texHalfLinear = true;
support.texHalf = true;
support.clipDist = true;
Core::width = DISPLAY_WIDTH;
Core::height = DISPLAY_HEIGHT;
@ -1198,7 +1194,7 @@ namespace GAPI {
}
inline mat4::ProjRange getProjRange() {
return mat4::PROJ_ZERO_POS;
return mat4::PROJ_NEG_POS;
}
mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
@ -1280,7 +1276,7 @@ namespace GAPI {
sceGxmBeginScene(Context::gxmContext, flags, target->renderTarget, NULL, NULL, NULL, colorSurface, &target->depthSurface);
}
active.viewport = Viewport(0, 0, 0, 0); // forcing viewport reset
active.viewport = short4(0, 0, 0, 0); // forcing viewport reset
}
void discardTarget(bool color, bool depth) {}
@ -1300,12 +1296,16 @@ namespace GAPI {
Context::checkPendings();
}
void setViewport(const Viewport &vp) {
void setViewport(const short4 &v) {
int vh = active.target ? active.target->height : Core::height;
int sw = vp.width / 2;
int sh = vp.height / 2;
sceGxmSetViewport(Context::gxmContext, float(vp.x + sw), float(sw), float(vh - vp.y - sh), float(-sh), 0.0f, 1.0f);
sceGxmSetRegionClip(Context::gxmContext, SCE_GXM_REGION_CLIP_OUTSIDE, vp.x, vh - vp.y - vp.height, vp.x + vp.width, vp.y + vp.height);
int sw = v.z / 2;
int sh = v.w / 2;
sceGxmSetViewport(Context::gxmContext, float(v.x + sw), float(sw), float(vh - v.y - sh), float(-sh), 0.0f, 1.0f);
}
void setScissor(const short4 &s) {
//int vh = active.target ? active.target->height : Core::height;
//sceGxmSetRegionClip(Context::gxmContext, SCE_GXM_REGION_CLIP_OUTSIDE, 0, 0, 256, 256);
}
void setDepthTest(bool enable) {

View File

@ -193,7 +193,7 @@ int main() {
osTimerFreq = sceRtcGetTickResolution();
osStartTime = Core::getTime();
Game::init("PSXDATA/LEVEL2.PSX");
Game::init();//"PSXDATA/LEVEL2.PSX");
// sceRazorGpuCaptureSetTrigger(100, "ux0:data/OpenLara/capture.sgx");
while (!Core::isQuit) {

View File

@ -98,7 +98,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>wcrt.lib;wsock32.lib;d3d9.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>wcrt.lib;wsock32.lib;d3d9.lib;d3d11.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<RandomizedBaseAddress>false</RandomizedBaseAddress>

View File

@ -29,9 +29,15 @@
#endif
struct VS_INPUT {
#ifdef _GAPI_GXM
float4 aCoord : POSITION;
float4 aNormal : NORMAL;
float4 aTexCoord : TEXCOORD0;
#else
int4 aCoord : POSITION;
int4 aNormal : NORMAL;
int4 aTexCoord : TEXCOORD0;
#endif
float4 aColor : COLOR0;
float4 aLight : COLOR1;
};
@ -93,7 +99,7 @@ struct VS_INPUT {
#define SAMPLE_3D(T,uv) tex3D(T, uv)
#define SAMPLE_CUBE(T,uv) texCUBE(T, uv)
#ifdef PIXEL
#if defined(PIXEL) && !defined(_GAPI_GXM)
#define POSITION VPOS
#endif
#endif
@ -114,10 +120,17 @@ float4 uPosScale[2] : register( c92 );
float4 uContacts[MAX_CONTACTS] : register( c98 );
// options for compose, shadow, ambient passes
#define OPT_AMBIENT 1
#define OPT_SHADOW 1
#define OPT_CONTACT 1
#define OPT_CAUSTICS 1
#ifdef _GAPI_GXM
//#define OPT_AMBIENT
//#define OPT_SHADOW
//#define OPT_CONTACT
//#define OPT_CAUSTICS
#else
#define OPT_AMBIENT
#define OPT_SHADOW
#define OPT_CONTACT
#define OPT_CAUSTICS
#endif
float4 pack(float value) {
float4 v = frac(value * float4(1.0, 255.0, 65025.0, 16581375.0));
@ -177,14 +190,14 @@ float calcFresnel(float NdotV, float f0) {
void applyFogUW(inout float3 color, float3 coord, float waterFogDist, float waterColorDist) {
float h = coord.y - uParam.y;
float3 dir = uViewPos.xyz - coord.xyz;
float dist;
float dist = lerp(length(dir), abs(h / normalize(dir).y), step(uViewPos.y, uParam.y));
/*
if (uViewPos.y < uParam.y) {
dist = abs(h / normalize(dir).y);
} else {
dist = length(dir);
}
*/
float fog = saturate(1.0 / exp(dist * waterFogDist));
dist += h;
color.xyz *= lerp((float3)1.0, UNDERWATER_COLOR, clamp(dist * waterColorDist, 0.0, 2.0));
@ -222,11 +235,11 @@ float getShadowValue(float3 lightVec, float4 lightProj) {
return rShadow + (1.0 - rShadow) * fade;
}
float getShadow(float3 lightVec, float3 normal, float4 lightProj) {
float getShadow(float3 lightVec, float4 lightProj) {
return getShadowValue(lightVec, lightProj);
}
float4 calcLightProj(float3 coord, float3 lightVec, float3 normal) {
float4 calcLightProj(float3 coord) {
return mul(uLightProj, float4(coord, 1.0));
}

View File

@ -37,11 +37,11 @@ VS_OUTPUT main(VS_INPUT In) {
float3 lv2 = (uLightPos[2].xyz - Out.coord) * uLightColor[2].w;
float3 lv3 = (uLightPos[3].xyz - Out.coord) * uLightColor[3].w;
if (OPT_AMBIENT) {
#ifdef OPT_AMBIENT
Out.ambient = calcAmbient(Out.normal.xyz);
} else {
#else
Out.ambient = min(uMaterial.yyy, In.aLight.xyz);
}
#endif
float4 lum, att, light;
lum.x = dot(Out.normal.xyz, normalize(lv0)); att.x = dot(lv0, lv0);
@ -57,21 +57,21 @@ VS_OUTPUT main(VS_INPUT In) {
Out.normal.w = saturate(1.0 / exp(length(Out.viewVec.xyz)));
#endif
if (OPT_SHADOW) {
#ifdef OPT_SHADOW
Out.light = light;
} else {
#else
Out.light.xyz = uLightColor[1].xyz * light.y + uLightColor[2].xyz * light.z + uLightColor[3].xyz * light.w;
Out.light.w = 0.0;
Out.light.xyz += Out.ambient + uLightColor[0].xyz * light.x;
}
#endif
Out.diffuse = float4(In.aColor.xyz * (uMaterial.x * 1.8), 1.0);
Out.diffuse *= uMaterial.w;
Out.pos = mul(uViewProj, float4(Out.coord, rBasisPos.w));
Out.lightProj = calcLightProj(Out.coord, normalize(uLightPos[0].xyz - Out.coord), Out.normal.xyz);
Out.lightProj = calcLightProj(Out.coord);
return Out;
}
@ -93,18 +93,18 @@ float4 main(VS_OUTPUT In) : COLOR0 {
float rSpecular = 0.0;
float3 light;
if (OPT_SHADOW) {
#ifdef OPT_SHADOW
light = uLightColor[1].xyz * In.light.y + uLightColor[2].xyz * In.light.z + uLightColor[3].xyz * In.light.w;
float rShadow = getShadow(lightVec, normal, In.lightProj);
float rShadow = getShadow(lightVec, In.lightProj);
rSpecular = (uMaterial.z + 0.03) * rShadow;
light += In.ambient + uLightColor[0].xyz * (In.light.x * rShadow);
} else {
#else
light = In.light.xyz;
}
#endif
if (OPT_CAUSTICS) {
#ifdef OPT_CAUSTICS
light += calcCaustics(In.coord, normal);
}
#endif
color.xyz *= light;

View File

@ -52,22 +52,22 @@ VS_OUTPUT main(VS_INPUT In) {
Out.normal.w = saturate(1.0 / exp(length(viewVec.xyz)));
#endif
if (OPT_SHADOW) {
#ifdef OPT_SHADOW
Out.light = light;
Out.lightMap = In.aLight.rgb * light.x;
} else {
#else
Out.light.xyz = uLightColor[1].xyz * light.y + uLightColor[2].xyz * light.z + uLightColor[3].xyz * light.w;
Out.light.w = 0.0;
Out.light.xyz += In.aLight.rgb * light.x;
Out.lightMap = 0.0;
}
#endif
Out.diffuse = float4(In.aColor.rgb * (uMaterial.x * 1.8), 1.0);
Out.diffuse *= uMaterial.w;
Out.pos = mul(uViewProj, float4(Out.coord, 1.0));
Out.lightProj = calcLightProj(Out.coord, normalize(uLightPos[0].xyz - Out.coord), Out.normal.xyz);
Out.lightProj = calcLightProj(Out.coord);
return Out;
}
@ -83,25 +83,27 @@ float4 main(VS_OUTPUT In) : COLOR0 {
color *= In.diffuse;
float3 lightVec = (uLightPos[0].xyz - In.coord) * uLightColor[0].w;
float3 normal = normalize(In.normal.xyz);
float3 light;
if (OPT_SHADOW) {
#ifdef OPT_SHADOW
float3 lightVec = (uLightPos[0].xyz - In.coord) * uLightColor[0].w;
light = uLightColor[1].xyz * In.light.y + uLightColor[2].xyz * In.light.z + uLightColor[3].xyz * In.light.w;
float rShadow = getShadow(lightVec, normal, In.lightProj);
float rShadow = getShadow(lightVec, In.lightProj);
light += lerp(In.ambient, In.lightMap, rShadow);
} else {
#else
light = In.light.xyz;
}
#endif
if (OPT_CAUSTICS) {
#if defined(OPT_CAUSTICS) || defined(OPT_CONTACT)
float3 normal = normalize(In.normal.xyz);
#endif
#ifdef OPT_CAUSTICS
light += calcCaustics(In.coord, normal);
}
#endif
if (OPT_CONTACT) {
#ifdef OPT_CONTACT
light *= getContactAO(In.coord, normal) * 0.5 + 0.5;
}
#endif
color.xyz *= light;

View File

@ -73,8 +73,6 @@ float4 main(VS_OUTPUT In) : COLOR0 {
color *= In.diffuse;
float3 normal = normalize(In.normal.xyz);
float3 light = In.light.xyz;
color.xyz *= light;

View File

@ -30,7 +30,13 @@ VS_OUTPUT main(VS_INPUT In) {
#else // PIXEL
float4 main(VS_OUTPUT In) : COLOR0 {
#if defined(ALPHA_TEST) || !defined(SHADOW_DEPTH)
#define PS_PARAMS VS_OUTPUT In
#else
#define PS_PARAMS
#endif
float4 main(PS_PARAMS) : COLOR0 {
#ifdef ALPHA_TEST
clip(SAMPLE_2D_LINEAR(sDiffuse, In.texCoord.xy).a - ALPHA_REF);
#endif