mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
add d3d9 lanczos2 shader
This commit is contained in:
parent
2a5bd91629
commit
e2ed1930c3
1241
inc/d3d9shader.h
1241
inc/d3d9shader.h
File diff suppressed because it is too large
Load Diff
1
inc/dd.h
1
inc/dd.h
@ -39,6 +39,7 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute
|
|||||||
#define FILTER_NEAREST 0
|
#define FILTER_NEAREST 0
|
||||||
#define FILTER_LINEAR 1
|
#define FILTER_LINEAR 1
|
||||||
#define FILTER_CUBIC 2
|
#define FILTER_CUBIC 2
|
||||||
|
#define FILTER_LANCZOS 3
|
||||||
|
|
||||||
#define SDM_MODE_SET_BY_GAME 0x00000001l
|
#define SDM_MODE_SET_BY_GAME 0x00000001l
|
||||||
#define SDM_LEAVE_WINDOWED 0x00000002l
|
#define SDM_LEAVE_WINDOWED 0x00000002l
|
||||||
|
@ -298,7 +298,7 @@ static void cfg_create_ini()
|
|||||||
"resizable=true\n"
|
"resizable=true\n"
|
||||||
"\n"
|
"\n"
|
||||||
"; Upscaling filter for the direct3d9* renderers\n"
|
"; Upscaling filter for the direct3d9* renderers\n"
|
||||||
"; Possible values: 0 = nearest-neighbor, 1 = bilinear, 2 = bicubic (16/32bit color depth games only)\n"
|
"; Possible values: 0 = nearest-neighbor, 1 = bilinear, 2 = bicubic, 3 = lanczos (bicubic/lanczos only support 16/32bit color depth games)\n"
|
||||||
"d3d9_filter=2\n"
|
"d3d9_filter=2\n"
|
||||||
"\n"
|
"\n"
|
||||||
"; Enable upscale hack for high resolution patches (Supports C&C1, Red Alert 1 and KKND Xtreme)\n"
|
"; Enable upscale hack for high resolution patches (Supports C&C1, Red Alert 1 and KKND Xtreme)\n"
|
||||||
|
@ -318,10 +318,27 @@ static BOOL d3d9_create_resources()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IDirect3DDevice9_CreatePixelShader(
|
if (g_ddraw->d3d9_filter == FILTER_LANCZOS)
|
||||||
g_d3d9.device,
|
{
|
||||||
(DWORD*)D3D9_CATMULL_ROM_SHADER,
|
BOOL error = FAILED(
|
||||||
&g_d3d9.pixel_shader_upscale);
|
IDirect3DDevice9_CreatePixelShader(
|
||||||
|
g_d3d9.device,
|
||||||
|
(DWORD*)D3D9_LANCZOS2_SHADER,
|
||||||
|
&g_d3d9.pixel_shader_upscale));
|
||||||
|
|
||||||
|
if (error || !g_d3d9.pixel_shader_upscale)
|
||||||
|
{
|
||||||
|
g_ddraw->d3d9_filter = FILTER_CUBIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_ddraw->d3d9_filter == FILTER_CUBIC)
|
||||||
|
{
|
||||||
|
IDirect3DDevice9_CreatePixelShader(
|
||||||
|
g_d3d9.device,
|
||||||
|
(DWORD*)D3D9_CATMULL_ROM_SHADER,
|
||||||
|
&g_d3d9.pixel_shader_upscale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_d3d9.vertex_buf && (g_d3d9.pixel_shader || g_ddraw->bpp == 16 || g_ddraw->bpp == 32) && !err;
|
return g_d3d9.vertex_buf && (g_d3d9.pixel_shader || g_ddraw->bpp == 16 || g_ddraw->bpp == 32) && !err;
|
||||||
@ -359,11 +376,22 @@ static BOOL d3d9_set_states()
|
|||||||
{
|
{
|
||||||
if (g_ddraw->d3d9_filter)
|
if (g_ddraw->d3d9_filter)
|
||||||
{
|
{
|
||||||
if (SUCCEEDED(IDirect3DDevice9_SetSamplerState(g_d3d9.device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR)) &&
|
if (g_ddraw->d3d9_filter == FILTER_LANCZOS &&
|
||||||
|
g_d3d9.pixel_shader_upscale &&
|
||||||
|
(g_ddraw->render.viewport.width != g_ddraw->width ||
|
||||||
|
g_ddraw->render.viewport.height != g_ddraw->height) &&
|
||||||
|
SUCCEEDED(IDirect3DDevice9_SetPixelShader(g_d3d9.device, g_d3d9.pixel_shader_upscale)))
|
||||||
|
{
|
||||||
|
float texture_size[4] = { (float)g_d3d9.tex_width, (float)g_d3d9.tex_height, 0, 0 };
|
||||||
|
err = err || FAILED(IDirect3DDevice9_SetPixelShaderConstantF(g_d3d9.device, 0, texture_size, 1));
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
SUCCEEDED(IDirect3DDevice9_SetSamplerState(g_d3d9.device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR)) &&
|
||||||
SUCCEEDED(IDirect3DDevice9_SetSamplerState(g_d3d9.device, 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR)) &&
|
SUCCEEDED(IDirect3DDevice9_SetSamplerState(g_d3d9.device, 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR)) &&
|
||||||
g_ddraw->d3d9_filter == FILTER_CUBIC &&
|
g_ddraw->d3d9_filter == FILTER_CUBIC &&
|
||||||
g_d3d9.pixel_shader_upscale &&
|
g_d3d9.pixel_shader_upscale &&
|
||||||
(g_ddraw->render.viewport.width != g_ddraw->width || g_ddraw->render.viewport.height != g_ddraw->height) &&
|
(g_ddraw->render.viewport.width != g_ddraw->width ||
|
||||||
|
g_ddraw->render.viewport.height != g_ddraw->height) &&
|
||||||
SUCCEEDED(IDirect3DDevice9_SetPixelShader(g_d3d9.device, g_d3d9.pixel_shader_upscale)))
|
SUCCEEDED(IDirect3DDevice9_SetPixelShader(g_d3d9.device, g_d3d9.pixel_shader_upscale)))
|
||||||
{
|
{
|
||||||
float texture_size[4] = { (float)g_d3d9.tex_width, (float)g_d3d9.tex_height, 0, 0 };
|
float texture_size[4] = { (float)g_d3d9.tex_width, (float)g_d3d9.tex_height, 0, 0 };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user