mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 15:40:28 +00:00
(HLSL) D3D device ptr for shader_hlsl.c
This commit is contained in:
parent
a50a9a6ba1
commit
f4f2ff386a
@ -346,7 +346,7 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
|
||||
// D3DCREATE_HARDWARE_VERTEXPROCESSING is ignored on 360
|
||||
ret = Direct3D_CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &vid->d3dpp, &vid->xdk360_render_device);
|
||||
|
||||
hlsl_init(g_settings.video.cg_shader_path);
|
||||
hlsl_init(g_settings.video.cg_shader_path, vid->xdk360_render_device);
|
||||
|
||||
vid->lpTexture = (D3DTexture*) D3DDevice_CreateTexture(512, 512, 1, 1, 0, D3DFMT_LIN_X1R5G5B5,
|
||||
0, D3DRTYPE_TEXTURE);
|
||||
@ -434,8 +434,8 @@ static bool xdk360_gfx_frame(void *data, const void *frame,
|
||||
vid->last_height = height;
|
||||
}
|
||||
|
||||
hlsl_use(vid->xdk360_render_device, 0);
|
||||
hlsl_set_params(vid->xdk360_render_device);
|
||||
hlsl_use(0);
|
||||
hlsl_set_params();
|
||||
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
D3DTexture_LockRect(vid->lpTexture, 0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK);
|
||||
|
@ -32,6 +32,7 @@ struct hlsl_program
|
||||
XMMATRIX mvp;
|
||||
};
|
||||
|
||||
static IDirect3DDevice9 * d3d_device_ptr;
|
||||
static struct hlsl_program prg[SSNES_HLSL_MAX_SHADERS] = {0};
|
||||
static bool hlsl_active = false;
|
||||
static unsigned active_index = 0;
|
||||
@ -76,12 +77,12 @@ void hlsl_set_proj_matrix(XMMATRIX rotation_value)
|
||||
prg[active_index].mvp = rotation_value;
|
||||
}
|
||||
|
||||
void hlsl_set_params(IDirect3DDevice9 * device)
|
||||
void hlsl_set_params(void)
|
||||
{
|
||||
if (!hlsl_active)
|
||||
return;
|
||||
|
||||
device->SetVertexShaderConstantF(0, (FLOAT*)&prg[active_index].mvp, 4);
|
||||
d3d_device_ptr->SetVertexShaderConstantF(0, (FLOAT*)&prg[active_index].mvp, 4);
|
||||
}
|
||||
|
||||
static bool load_program(unsigned index, const char *prog, bool path_is_file)
|
||||
@ -171,6 +172,8 @@ static void hlsl_deinit_state(void)
|
||||
{
|
||||
hlsl_active = false;
|
||||
|
||||
d3d_device_ptr = NULL;
|
||||
|
||||
hlsl_deinit_progs();
|
||||
}
|
||||
|
||||
@ -179,8 +182,13 @@ static bool load_preset(const char *path)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hlsl_init(const char *path)
|
||||
bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr)
|
||||
{
|
||||
if (device_ptr != NULL)
|
||||
d3d_device_ptr = device_ptr;
|
||||
else
|
||||
return false;
|
||||
|
||||
if (strstr(path, ".cgp"))
|
||||
{
|
||||
if (!load_preset(path))
|
||||
@ -197,13 +205,13 @@ bool hlsl_init(const char *path)
|
||||
return true;
|
||||
}
|
||||
|
||||
void hlsl_use(IDirect3DDevice9 * device, unsigned index)
|
||||
void hlsl_use(unsigned index)
|
||||
{
|
||||
if (hlsl_active && prg[index].vprg && prg[index].fprg)
|
||||
{
|
||||
active_index = index;
|
||||
D3DDevice_SetVertexShader(device, prg[index].vprg);
|
||||
D3DDevice_SetPixelShader(device, prg[index].fprg);
|
||||
D3DDevice_SetVertexShader(d3d_device_ptr, prg[index].vprg);
|
||||
D3DDevice_SetPixelShader(d3d_device_ptr, prg[index].fprg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,15 +19,15 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
bool hlsl_init(const char *path);
|
||||
bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr);
|
||||
|
||||
void hlsl_deinit(void);
|
||||
|
||||
void hlsl_set_proj_matrix(XMMATRIX rotation_value);
|
||||
|
||||
void hlsl_set_params(IDirect3DDevice9 * device);
|
||||
void hlsl_set_params(void);
|
||||
|
||||
void hlsl_use(IDirect3DDevice9 * device, unsigned index);
|
||||
void hlsl_use(unsigned index);
|
||||
|
||||
#define SSNES_HLSL_MAX_SHADERS 16
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user