mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Split up menu display drivers for D3D8/D3D9 into separate drivers;
split up d3d_common into separate files
This commit is contained in:
parent
0566b056a5
commit
b4a743fff4
@ -1305,21 +1305,27 @@ endif
|
||||
|
||||
ifeq ($(HAVE_D3D8), 1)
|
||||
DEFINES += -DHAVE_D3D8
|
||||
OBJ += gfx/drivers/d3d9.o
|
||||
OBJ += gfx/drivers/d3d8.o
|
||||
OBJ += gfx/common/d3d8_common.o
|
||||
|
||||
ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
OBJ += menu/drivers_display/menu_display_d3d8.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_D3D9), 1)
|
||||
DEFINES += -DHAVE_D3D9
|
||||
OBJ += gfx/drivers/d3d9.o
|
||||
OBJ += gfx/common/d3d9_common.o
|
||||
|
||||
ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
OBJ += menu/drivers_display/menu_display_d3d9.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_D3D_COMMON), 1)
|
||||
DEFINES += -DHAVE_D3D
|
||||
OBJ += gfx/common/d3d_common.o
|
||||
|
||||
ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
OBJ += menu/drivers_display/menu_display_d3d.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_SLANG),1)
|
||||
|
1086
gfx/common/d3d8_common.c
Normal file
1086
gfx/common/d3d8_common.c
Normal file
File diff suppressed because it is too large
Load Diff
212
gfx/common/d3d8_common.h
Normal file
212
gfx/common/d3d8_common.h
Normal file
@ -0,0 +1,212 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _D3D8_COMMON_H
|
||||
#define _D3D8_COMMON_H
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
#include "../video_driver.h"
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
bool d3d8_swap(void *data, void *dev);
|
||||
|
||||
void *d3d8_vertex_buffer_new(void *dev,
|
||||
unsigned length, unsigned usage, unsigned fvf,
|
||||
INT32 pool, void *handle);
|
||||
|
||||
void *d3d8_vertex_buffer_lock(void *data);
|
||||
void d3d8_vertex_buffer_unlock(void *data);
|
||||
|
||||
void d3d8_vertex_buffer_free(void *vertex_data, void *vertex_declaration);
|
||||
|
||||
bool d3d8_texture_get_level_desc(void *tex,
|
||||
unsigned idx, void *_ppsurface_level);
|
||||
|
||||
bool d3d8_texture_get_surface_level(void *tex,
|
||||
unsigned idx, void **_ppsurface_level);
|
||||
|
||||
void *d3d8_texture_new(void *dev,
|
||||
const char *path, unsigned width, unsigned height,
|
||||
unsigned miplevels, unsigned usage, INT32 format,
|
||||
INT32 pool, unsigned filter, unsigned mipfilter,
|
||||
INT32 color_key, void *src_info,
|
||||
PALETTEENTRY *palette, bool want_mipmap);
|
||||
|
||||
void d3d8_set_stream_source(void *dev, unsigned stream_no,
|
||||
void *stream_vertbuf, unsigned offset_bytes,
|
||||
unsigned stride);
|
||||
|
||||
void d3d8_texture_free(void *tex);
|
||||
|
||||
void d3d8_set_transform(void *dev,
|
||||
INT32 state, const void *_matrix);
|
||||
|
||||
void d3d8_set_sampler_address_u(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
void d3d8_set_sampler_address_v(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
void d3d8_set_sampler_minfilter(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
void d3d8_set_sampler_magfilter(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
void d3d8_set_sampler_mipfilter(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
bool d3d8_begin_scene(void *dev);
|
||||
|
||||
void d3d8_end_scene(void *dev);
|
||||
|
||||
void d3d8_draw_primitive(void *dev,
|
||||
INT32 type, unsigned start, unsigned count);
|
||||
|
||||
void d3d8_clear(void *dev,
|
||||
unsigned count, const void *rects, unsigned flags,
|
||||
INT32 color, float z, unsigned stencil);
|
||||
|
||||
bool d3d8_lock_rectangle(void *tex,
|
||||
unsigned level, void *lock_rect, RECT *rect,
|
||||
unsigned rectangle_height, unsigned flags);
|
||||
|
||||
void d3d8_lock_rectangle_clear(void *tex,
|
||||
unsigned level, void *lock_rect, RECT *rect,
|
||||
unsigned rectangle_height, unsigned flags);
|
||||
|
||||
void d3d8_unlock_rectangle(void *tex);
|
||||
|
||||
void d3d8_set_texture(void *dev, unsigned sampler,
|
||||
void *tex_data);
|
||||
|
||||
bool d3d8_create_vertex_shader(void *dev,
|
||||
const DWORD *a, void **b);
|
||||
|
||||
bool d3d8_create_pixel_shader(void *dev,
|
||||
const DWORD *a, void **b);
|
||||
|
||||
void d3d8_free_vertex_shader(void *dev, void *data);
|
||||
|
||||
bool d3d8_set_vertex_shader(void *dev, unsigned index,
|
||||
void *data);
|
||||
|
||||
void d3d8_texture_blit(unsigned pixel_size,
|
||||
void *tex,
|
||||
void *lr, const void *frame,
|
||||
unsigned width, unsigned height, unsigned pitch);
|
||||
|
||||
bool d3d8_vertex_declaration_new(void *dev,
|
||||
const void *vertex_data, void **decl_data);
|
||||
|
||||
void d3d8_vertex_declaration_free(void *data);
|
||||
|
||||
void d3d8_set_viewports(void *dev, void *vp);
|
||||
|
||||
void d3d8_enable_blend_func(void *data);
|
||||
|
||||
void d3d8_disable_blend_func(void *data);
|
||||
|
||||
void d3d8_set_vertex_declaration(void *data, void *vertex_data);
|
||||
|
||||
void d3d8_enable_alpha_blend_texture_func(void *data);
|
||||
|
||||
void d3d8_frame_postprocess(void *data);
|
||||
|
||||
void d3d8_surface_free(void *data);
|
||||
|
||||
bool d3d8_device_get_render_target_data(void *dev,
|
||||
void *_src, void *_dst);
|
||||
|
||||
bool d3d8_device_get_render_target(void *dev,
|
||||
unsigned idx, void **data);
|
||||
|
||||
void d3d8_device_set_render_target(void *dev, unsigned idx,
|
||||
void *data);
|
||||
|
||||
bool d3d8_get_render_state(void *data,
|
||||
INT32 state, DWORD *value);
|
||||
|
||||
void d3d8_set_render_state(void *data,
|
||||
INT32 state, DWORD value);
|
||||
|
||||
void d3d8_device_set_render_target(void *dev, unsigned idx,
|
||||
void *data);
|
||||
|
||||
bool d3d8_device_create_offscreen_plain_surface(
|
||||
void *dev,
|
||||
unsigned width,
|
||||
unsigned height,
|
||||
unsigned format,
|
||||
unsigned pool,
|
||||
void **surf_data,
|
||||
void *data);
|
||||
|
||||
bool d3d8_surface_lock_rect(void *data, void *data2);
|
||||
|
||||
void d3d8_surface_unlock_rect(void *data);
|
||||
|
||||
bool d3d8_get_adapter_display_mode(void *d3d,
|
||||
unsigned idx,
|
||||
void *display_mode);
|
||||
|
||||
bool d3d8_create_device(void *dev,
|
||||
void *d3dpp,
|
||||
void *d3d,
|
||||
HWND focus_window,
|
||||
unsigned cur_mon_id);
|
||||
|
||||
bool d3d8_reset(void *dev, void *d3dpp);
|
||||
|
||||
bool d3d8_device_get_backbuffer(void *dev,
|
||||
unsigned idx, unsigned swapchain_idx,
|
||||
unsigned backbuffer_type, void **data);
|
||||
|
||||
void d3d8_device_free(void *dev, void *pd3d);
|
||||
|
||||
void *d3d8_create(void);
|
||||
|
||||
bool d3d8_initialize_symbols(enum gfx_ctx_api api);
|
||||
|
||||
void d3d8_deinitialize_symbols(void);
|
||||
|
||||
bool d3d8_check_device_type(void *d3d,
|
||||
unsigned idx,
|
||||
INT32 disp_format,
|
||||
INT32 backbuffer_format,
|
||||
bool windowed_mode);
|
||||
|
||||
bool d3d8x_create_font_indirect(void *dev,
|
||||
void *desc, void **font_data);
|
||||
|
||||
void d3d8x_font_draw_text(void *data, void *sprite_data, void *string_data,
|
||||
unsigned count, void *rect_data, unsigned format, unsigned color);
|
||||
|
||||
void d3d8x_font_get_text_metrics(void *data, void *metrics);
|
||||
|
||||
void d3d8x_font_release(void *data);
|
||||
|
||||
INT32 d3d8_translate_filter(unsigned type);
|
||||
|
||||
INT32 d3d8_get_rgb565_format(void);
|
||||
INT32 d3d8_get_argb8888_format(void);
|
||||
INT32 d3d8_get_xrgb8888_format(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
1571
gfx/common/d3d9_common.c
Normal file
1571
gfx/common/d3d9_common.c
Normal file
File diff suppressed because it is too large
Load Diff
249
gfx/common/d3d9_common.h
Normal file
249
gfx/common/d3d9_common.h
Normal file
@ -0,0 +1,249 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _D3D9_COMMON_H
|
||||
#define _D3D9_COMMON_H
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
#include "../video_driver.h"
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
bool d3d9_swap(void *data, void *dev);
|
||||
|
||||
void *d3d9_vertex_buffer_new(void *dev,
|
||||
unsigned length, unsigned usage, unsigned fvf,
|
||||
INT32 pool, void *handle);
|
||||
|
||||
void *d3d9_vertex_buffer_lock(void *data);
|
||||
void d3d9_vertex_buffer_unlock(void *data);
|
||||
|
||||
void d3d9_vertex_buffer_free(void *vertex_data, void *vertex_declaration);
|
||||
|
||||
bool d3d9_texture_get_level_desc(void *tex,
|
||||
unsigned idx, void *_ppsurface_level);
|
||||
|
||||
bool d3d9_texture_get_surface_level(void *tex,
|
||||
unsigned idx, void **_ppsurface_level);
|
||||
|
||||
void *d3d9_texture_new(void *dev,
|
||||
const char *path, unsigned width, unsigned height,
|
||||
unsigned miplevels, unsigned usage, INT32 format,
|
||||
INT32 pool, unsigned filter, unsigned mipfilter,
|
||||
INT32 color_key, void *src_info,
|
||||
PALETTEENTRY *palette, bool want_mipmap);
|
||||
|
||||
void d3d9_set_stream_source(void *dev, unsigned stream_no,
|
||||
void *stream_vertbuf, unsigned offset_bytes,
|
||||
unsigned stride);
|
||||
|
||||
void d3d9_texture_free(void *tex);
|
||||
|
||||
void d3d9_set_transform(void *dev,
|
||||
INT32 state, const void *_matrix);
|
||||
|
||||
void d3d9_set_sampler_address_u(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
void d3d9_set_sampler_address_v(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
void d3d9_set_sampler_minfilter(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
void d3d9_set_sampler_magfilter(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
void d3d9_set_sampler_mipfilter(void *dev,
|
||||
unsigned sampler, unsigned value);
|
||||
|
||||
bool d3d9_begin_scene(void *dev);
|
||||
|
||||
void d3d9_end_scene(void *dev);
|
||||
|
||||
void d3d9_draw_primitive(void *dev,
|
||||
INT32 type, unsigned start, unsigned count);
|
||||
|
||||
void d3d9_clear(void *dev,
|
||||
unsigned count, const void *rects, unsigned flags,
|
||||
INT32 color, float z, unsigned stencil);
|
||||
|
||||
bool d3d9_lock_rectangle(void *tex,
|
||||
unsigned level, void *lock_rect, RECT *rect,
|
||||
unsigned rectangle_height, unsigned flags);
|
||||
|
||||
void d3d9_lock_rectangle_clear(void *tex,
|
||||
unsigned level, void *lock_rect, RECT *rect,
|
||||
unsigned rectangle_height, unsigned flags);
|
||||
|
||||
void d3d9_unlock_rectangle(void *tex);
|
||||
|
||||
void d3d9_set_texture(void *dev, unsigned sampler,
|
||||
void *tex_data);
|
||||
|
||||
bool d3d9_create_vertex_shader(void *dev,
|
||||
const DWORD *a, void **b);
|
||||
|
||||
bool d3d9_create_pixel_shader(void *dev,
|
||||
const DWORD *a, void **b);
|
||||
|
||||
void d3d9_free_pixel_shader(void *dev, void *data);
|
||||
|
||||
void d3d9_free_vertex_shader(void *dev, void *data);
|
||||
|
||||
bool d3d9_set_pixel_shader(void *dev, void *data);
|
||||
|
||||
bool d3d9_set_vertex_shader(void *dev, unsigned index,
|
||||
void *data);
|
||||
|
||||
bool d3d9_set_vertex_shader_constantf(void *dev,
|
||||
UINT start_register,const float* constant_data, unsigned vector4f_count);
|
||||
|
||||
void d3d9_texture_blit(unsigned pixel_size,
|
||||
void *tex,
|
||||
void *lr, const void *frame,
|
||||
unsigned width, unsigned height, unsigned pitch);
|
||||
|
||||
bool d3d9_vertex_declaration_new(void *dev,
|
||||
const void *vertex_data, void **decl_data);
|
||||
|
||||
void d3d9_vertex_declaration_free(void *data);
|
||||
|
||||
void d3d9_set_viewports(void *dev, void *vp);
|
||||
|
||||
void d3d9_enable_blend_func(void *data);
|
||||
|
||||
void d3d9_disable_blend_func(void *data);
|
||||
|
||||
void d3d9_set_vertex_declaration(void *data, void *vertex_data);
|
||||
|
||||
void d3d9_enable_alpha_blend_texture_func(void *data);
|
||||
|
||||
void d3d9_frame_postprocess(void *data);
|
||||
|
||||
void d3d9_surface_free(void *data);
|
||||
|
||||
bool d3d9_device_get_render_target_data(void *dev,
|
||||
void *_src, void *_dst);
|
||||
|
||||
bool d3d9_device_get_render_target(void *dev,
|
||||
unsigned idx, void **data);
|
||||
|
||||
void d3d9_device_set_render_target(void *dev, unsigned idx,
|
||||
void *data);
|
||||
|
||||
bool d3d9_get_render_state(void *data,
|
||||
INT32 state, DWORD *value);
|
||||
|
||||
void d3d9_set_render_state(void *data,
|
||||
INT32 state, DWORD value);
|
||||
|
||||
void d3d9_device_set_render_target(void *dev, unsigned idx,
|
||||
void *data);
|
||||
|
||||
bool d3d9_device_create_offscreen_plain_surface(
|
||||
void *dev,
|
||||
unsigned width,
|
||||
unsigned height,
|
||||
unsigned format,
|
||||
unsigned pool,
|
||||
void **surf_data,
|
||||
void *data);
|
||||
|
||||
bool d3d9_surface_lock_rect(void *data, void *data2);
|
||||
|
||||
void d3d9_surface_unlock_rect(void *data);
|
||||
|
||||
bool d3d9_get_adapter_display_mode(void *d3d,
|
||||
unsigned idx,
|
||||
void *display_mode);
|
||||
|
||||
bool d3d9_create_device(void *dev,
|
||||
void *d3dpp,
|
||||
void *d3d,
|
||||
HWND focus_window,
|
||||
unsigned cur_mon_id);
|
||||
|
||||
bool d3d9_reset(void *dev, void *d3dpp);
|
||||
|
||||
bool d3d9_device_get_backbuffer(void *dev,
|
||||
unsigned idx, unsigned swapchain_idx,
|
||||
unsigned backbuffer_type, void **data);
|
||||
|
||||
void d3d9_device_free(void *dev, void *pd3d);
|
||||
|
||||
void *d3d9_create(void);
|
||||
|
||||
bool d3d9_initialize_symbols(enum gfx_ctx_api api);
|
||||
|
||||
void d3d9_deinitialize_symbols(void);
|
||||
|
||||
bool d3d9_check_device_type(void *d3d,
|
||||
unsigned idx,
|
||||
INT32 disp_format,
|
||||
INT32 backbuffer_format,
|
||||
bool windowed_mode);
|
||||
|
||||
bool d3d9x_create_font_indirect(void *dev,
|
||||
void *desc, void **font_data);
|
||||
|
||||
void d3d9x_font_draw_text(void *data, void *sprite_data, void *string_data,
|
||||
unsigned count, void *rect_data, unsigned format, unsigned color);
|
||||
|
||||
void d3d9x_font_get_text_metrics(void *data, void *metrics);
|
||||
|
||||
void d3dxbuffer_release(void *data);
|
||||
|
||||
void d3d9x_font_release(void *data);
|
||||
|
||||
INT32 d3d9_translate_filter(unsigned type);
|
||||
|
||||
bool d3d9x_compile_shader(
|
||||
const char *src,
|
||||
unsigned src_data_len,
|
||||
const void *pdefines,
|
||||
void *pinclude,
|
||||
const char *pfunctionname,
|
||||
const char *pprofile,
|
||||
unsigned flags,
|
||||
void *ppshader,
|
||||
void *pperrormsgs,
|
||||
void *ppconstanttable);
|
||||
|
||||
bool d3d9x_compile_shader_from_file(
|
||||
const char *src,
|
||||
const void *pdefines,
|
||||
void *pinclude,
|
||||
const char *pfunctionname,
|
||||
const char *pprofile,
|
||||
unsigned flags,
|
||||
void *ppshader,
|
||||
void *pperrormsgs,
|
||||
void *ppconstanttable);
|
||||
|
||||
const void *d3d9x_get_buffer_ptr(void *data);
|
||||
|
||||
const bool d3d9x_constant_table_set_float(void *p,
|
||||
void *a, const void *b, float val);
|
||||
|
||||
INT32 d3d9_get_rgb565_format(void);
|
||||
INT32 d3d9_get_argb8888_format(void);
|
||||
INT32 d3d9_get_xrgb8888_format(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,10 @@ typedef struct d3d_texture
|
||||
INT32 pool;
|
||||
} d3d_texture_t;
|
||||
|
||||
#ifndef BYTE_CLAMP
|
||||
#define BYTE_CLAMP(i) (int) ((((i) > 255) ? 255 : (((i) < 0) ? 0 : (i))))
|
||||
#endif
|
||||
|
||||
#ifndef D3DCOLOR_ARGB
|
||||
#define D3DCOLOR_ARGB(_a, _r, _g, _b) ( (DWORD)( ( ( (_a)&0xff)<<24)|( ( (_r)&0xff)<<16)|( ( (_g)&0xff)<<8)|( (_b)&0xff) ) )
|
||||
#endif
|
||||
|
@ -108,7 +108,5 @@ typedef struct d3d_video
|
||||
overlay_t *overlays;
|
||||
} d3d_video_t;
|
||||
|
||||
void d3d_make_d3dpp(void *data, const video_info_t *info, void *_d3dpp);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "d3d.h"
|
||||
#include "../../defines/d3d_defines.h"
|
||||
#include "../common/d3d8_common.h"
|
||||
#include "../common/d3d_common.h"
|
||||
#include "../video_coord_array.h"
|
||||
#include "../../configuration.h"
|
||||
@ -93,13 +94,13 @@ static void d3d8_renderchain_set_mvp(
|
||||
|
||||
d3d_matrix_identity(&matrix);
|
||||
|
||||
d3d_set_transform(d3d->dev, D3DTS_PROJECTION, &matrix);
|
||||
d3d_set_transform(d3d->dev, D3DTS_VIEW, &matrix);
|
||||
d3d8_set_transform(d3d->dev, D3DTS_PROJECTION, &matrix);
|
||||
d3d8_set_transform(d3d->dev, D3DTS_VIEW, &matrix);
|
||||
|
||||
if (mat_data)
|
||||
d3d_matrix_transpose(&matrix, mat_data);
|
||||
|
||||
d3d_set_transform(d3d->dev, D3DTS_WORLD, &matrix);
|
||||
d3d8_set_transform(d3d->dev, D3DTS_WORLD, &matrix);
|
||||
}
|
||||
|
||||
static bool d3d8_renderchain_create_first_pass(void *data,
|
||||
@ -109,7 +110,7 @@ static bool d3d8_renderchain_create_first_pass(void *data,
|
||||
LPDIRECT3DDEVICE8 d3dr = (LPDIRECT3DDEVICE8)d3d->dev;
|
||||
d3d8_renderchain_t *chain = (d3d8_renderchain_t*)d3d->renderchain_data;
|
||||
|
||||
chain->vertex_buf = (LPDIRECT3DVERTEXBUFFER8)d3d_vertex_buffer_new(d3dr, 4 * sizeof(Vertex),
|
||||
chain->vertex_buf = (LPDIRECT3DVERTEXBUFFER8)d3d8_vertex_buffer_new(d3dr, 4 * sizeof(Vertex),
|
||||
D3DUSAGE_WRITEONLY,
|
||||
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
|
||||
D3DPOOL_MANAGED,
|
||||
@ -118,22 +119,22 @@ static bool d3d8_renderchain_create_first_pass(void *data,
|
||||
if (!chain->vertex_buf)
|
||||
return false;
|
||||
|
||||
chain->tex = (LPDIRECT3DTEXTURE8)d3d_texture_new(d3dr, NULL,
|
||||
chain->tex = (LPDIRECT3DTEXTURE8)d3d8_texture_new(d3dr, NULL,
|
||||
chain->tex_w, chain->tex_h, 1, 0,
|
||||
info->rgb32
|
||||
?
|
||||
d3d_get_xrgb8888_format() : d3d_get_rgb565_format(),
|
||||
d3d8_get_xrgb8888_format() : d3d8_get_rgb565_format(),
|
||||
D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL,
|
||||
false);
|
||||
|
||||
if (!chain->tex)
|
||||
return false;
|
||||
|
||||
d3d_set_sampler_address_u(d3dr, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(d3dr, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_render_state(d3dr, D3DRS_LIGHTING, 0);
|
||||
d3d_set_render_state(d3dr, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
d3d_set_render_state(d3dr, D3DRS_ZENABLE, FALSE);
|
||||
d3d8_set_sampler_address_u(d3dr, 0, D3DTADDRESS_BORDER);
|
||||
d3d8_set_sampler_address_v(d3dr, 0, D3DTADDRESS_BORDER);
|
||||
d3d8_set_render_state(d3dr, D3DRS_LIGHTING, 0);
|
||||
d3d8_set_render_state(d3dr, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
d3d8_set_render_state(d3dr, D3DRS_ZENABLE, FALSE);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -199,9 +200,9 @@ static void d3d8_renderchain_set_vertices(void *data, unsigned pass,
|
||||
vert[2].color = 0xFFFFFFFF;
|
||||
vert[3].color = 0xFFFFFFFF;
|
||||
|
||||
verts = d3d_vertex_buffer_lock(chain->vertex_buf);
|
||||
verts = d3d8_vertex_buffer_lock(chain->vertex_buf);
|
||||
memcpy(verts, vert, sizeof(vert));
|
||||
d3d_vertex_buffer_unlock(chain->vertex_buf);
|
||||
d3d8_vertex_buffer_unlock(chain->vertex_buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,24 +213,24 @@ static void d3d8_renderchain_blit_to_texture(void *data, const void *frame,
|
||||
d3d8_renderchain_t *chain = (d3d8_renderchain_t*)data;
|
||||
LPDIRECT3DDEVICE8 d3dr = (LPDIRECT3DDEVICE8)chain->dev;
|
||||
|
||||
d3d_frame_postprocess(chain);
|
||||
d3d8_frame_postprocess(chain);
|
||||
|
||||
if (chain->last_width != width || chain->last_height != height)
|
||||
{
|
||||
d3d_lock_rectangle(chain->tex,
|
||||
d3d8_lock_rectangle(chain->tex,
|
||||
0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK);
|
||||
d3d_lock_rectangle_clear(chain->tex,
|
||||
d3d8_lock_rectangle_clear(chain->tex,
|
||||
0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK);
|
||||
}
|
||||
|
||||
/* Set the texture to NULL so D3D doesn't complain about it being in use... */
|
||||
d3d_set_texture(d3dr, 0, NULL);
|
||||
d3d8_set_texture(d3dr, 0, NULL);
|
||||
|
||||
if (d3d_lock_rectangle(chain->tex, 0, &d3dlr, NULL, 0, 0))
|
||||
if (d3d8_lock_rectangle(chain->tex, 0, &d3dlr, NULL, 0, 0))
|
||||
{
|
||||
d3d_texture_blit(chain->pixel_size, chain->tex,
|
||||
d3d8_texture_blit(chain->pixel_size, chain->tex,
|
||||
&d3dlr, frame, width, height, pitch);
|
||||
d3d_unlock_rectangle(chain->tex);
|
||||
d3d8_unlock_rectangle(chain->tex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,8 +242,8 @@ static void d3d8_renderchain_free(void *data)
|
||||
return;
|
||||
|
||||
if (chain->tex)
|
||||
d3d_texture_free(chain->tex);
|
||||
d3d_vertex_buffer_free(chain->vertex_buf, chain->vertex_decl);
|
||||
d3d8_texture_free(chain->tex);
|
||||
d3d8_vertex_buffer_free(chain->vertex_buf, chain->vertex_decl);
|
||||
|
||||
free(chain);
|
||||
}
|
||||
@ -276,19 +277,19 @@ static void d3d8_renderchain_render_pass(
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool video_smooth = settings->bools.video_smooth;
|
||||
|
||||
d3d_set_texture(d3dr, 0, chain->tex);
|
||||
d3d_set_sampler_magfilter(d3dr, pass_index, video_smooth ?
|
||||
d3d8_set_texture(d3dr, 0, chain->tex);
|
||||
d3d8_set_sampler_magfilter(d3dr, pass_index, video_smooth ?
|
||||
D3DTEXF_LINEAR : D3DTEXF_POINT);
|
||||
d3d_set_sampler_minfilter(d3dr, pass_index, video_smooth ?
|
||||
d3d8_set_sampler_minfilter(d3dr, pass_index, video_smooth ?
|
||||
D3DTEXF_LINEAR : D3DTEXF_POINT);
|
||||
|
||||
d3d_set_viewports(chain->dev, (D3DVIEWPORT8*)&d3d->final_viewport);
|
||||
d3d_set_vertex_shader(d3dr,
|
||||
d3d8_set_viewports(chain->dev, (D3DVIEWPORT8*)&d3d->final_viewport);
|
||||
d3d8_set_vertex_shader(d3dr,
|
||||
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
|
||||
NULL);
|
||||
d3d_set_stream_source(d3dr, 0, chain->vertex_buf, 0, sizeof(Vertex));
|
||||
d3d8_set_stream_source(d3dr, 0, chain->vertex_buf, 0, sizeof(Vertex));
|
||||
d3d8_renderchain_set_mvp(d3d, chain, NULL, &d3d->mvp_rotate);
|
||||
d3d_draw_primitive(d3dr, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
d3d8_draw_primitive(d3dr, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
}
|
||||
|
||||
static bool d3d8_renderchain_render(void *data, const void *frame,
|
||||
@ -452,7 +453,7 @@ static void d3d8_overlay_render(d3d_video_t *d3d,
|
||||
|
||||
if (!overlay->vert_buf)
|
||||
{
|
||||
overlay->vert_buf = d3d_vertex_buffer_new(
|
||||
overlay->vert_buf = d3d8_vertex_buffer_new(
|
||||
d3d->dev, sizeof(vert), D3DUSAGE_WRITEONLY,
|
||||
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
|
||||
D3DPOOL_MANAGED, NULL);
|
||||
@ -487,16 +488,16 @@ static void d3d8_overlay_render(d3d_video_t *d3d,
|
||||
vert[2].v = overlay->tex_coords[1] + overlay->tex_coords[3];
|
||||
vert[3].v = overlay->tex_coords[1] + overlay->tex_coords[3];
|
||||
|
||||
verts = d3d_vertex_buffer_lock(overlay->vert_buf);
|
||||
verts = d3d8_vertex_buffer_lock(overlay->vert_buf);
|
||||
memcpy(verts, vert, sizeof(vert));
|
||||
d3d_vertex_buffer_unlock(overlay->vert_buf);
|
||||
d3d8_vertex_buffer_unlock(overlay->vert_buf);
|
||||
|
||||
d3d_enable_blend_func(d3d->dev);
|
||||
d3d_set_vertex_shader(d3d->dev,
|
||||
d3d8_enable_blend_func(d3d->dev);
|
||||
d3d8_set_vertex_shader(d3d->dev,
|
||||
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
|
||||
NULL);
|
||||
|
||||
d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf,
|
||||
d3d8_set_stream_source(d3d->dev, 0, overlay->vert_buf,
|
||||
0, sizeof(*vert));
|
||||
|
||||
if (overlay->fullscreen)
|
||||
@ -508,21 +509,21 @@ static void d3d8_overlay_render(d3d_video_t *d3d,
|
||||
vp_full.Height = height;
|
||||
vp_full.MinZ = 0.0f;
|
||||
vp_full.MaxZ = 1.0f;
|
||||
d3d_set_viewports(d3d->dev, &vp_full);
|
||||
d3d8_set_viewports(d3d->dev, &vp_full);
|
||||
}
|
||||
|
||||
/* Render overlay. */
|
||||
d3d_set_texture(d3d->dev, 0, overlay->tex);
|
||||
d3d_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_LINEAR);
|
||||
d3d_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_LINEAR);
|
||||
d3d_draw_primitive(d3d->dev, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
d3d8_set_texture(d3d->dev, 0, overlay->tex);
|
||||
d3d8_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d8_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d8_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_LINEAR);
|
||||
d3d8_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_LINEAR);
|
||||
d3d8_draw_primitive(d3d->dev, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
|
||||
/* Restore previous state. */
|
||||
d3d_disable_blend_func(d3d->dev);
|
||||
d3d8_disable_blend_func(d3d->dev);
|
||||
|
||||
d3d_set_viewports(d3d->dev, &d3d->final_viewport);
|
||||
d3d8_set_viewports(d3d->dev, &d3d->final_viewport);
|
||||
}
|
||||
|
||||
static void d3d8_free_overlay(d3d_video_t *d3d, overlay_t *overlay)
|
||||
@ -530,8 +531,8 @@ static void d3d8_free_overlay(d3d_video_t *d3d, overlay_t *overlay)
|
||||
if (!d3d)
|
||||
return;
|
||||
|
||||
d3d_texture_free(overlay->tex);
|
||||
d3d_vertex_buffer_free(overlay->vert_buf, NULL);
|
||||
d3d8_texture_free(overlay->tex);
|
||||
d3d8_vertex_buffer_free(overlay->vert_buf, NULL);
|
||||
}
|
||||
|
||||
static void d3d8_deinit_chain(d3d_video_t *d3d)
|
||||
@ -549,7 +550,7 @@ static void d3d8_deinitialize(d3d_video_t *d3d)
|
||||
font_driver_free_osd();
|
||||
|
||||
d3d8_deinit_chain(d3d);
|
||||
d3d_vertex_buffer_free(d3d->menu_display.buffer, d3d->menu_display.decl);
|
||||
d3d8_vertex_buffer_free(d3d->menu_display.buffer, d3d->menu_display.decl);
|
||||
d3d->menu_display.buffer = NULL;
|
||||
d3d->menu_display.decl = NULL;
|
||||
}
|
||||
@ -561,12 +562,12 @@ static D3DFORMAT d3d8_get_color_format_backbuffer(bool rgb32, bool windowed)
|
||||
D3DFORMAT fmt = D3DFMT_X8R8G8B8;
|
||||
#ifdef _XBOX
|
||||
if (!rgb32)
|
||||
fmt = d3d_get_rgb565_format();
|
||||
fmt = d3d8_get_rgb565_format();
|
||||
#else
|
||||
if (windowed)
|
||||
{
|
||||
D3DDISPLAYMODE display_mode;
|
||||
if (d3d_get_adapter_display_mode(g_pD3D8, 0, &display_mode))
|
||||
if (d3d8_get_adapter_display_mode(g_pD3D8, 0, &display_mode))
|
||||
fmt = display_mode.Format;
|
||||
}
|
||||
#endif
|
||||
@ -649,7 +650,7 @@ static void d3d8_get_video_size(d3d_video_t *d3d,
|
||||
}
|
||||
#endif
|
||||
|
||||
void d3d8_make_d3dpp(void *data,
|
||||
static void d3d8_make_d3dpp(void *data,
|
||||
const video_info_t *info, void *_d3dpp)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
@ -760,7 +761,7 @@ static bool d3d8_init_base(void *data, const video_info_t *info)
|
||||
|
||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||
|
||||
g_pD3D8 = (LPDIRECT3D8)d3d_create();
|
||||
g_pD3D8 = (LPDIRECT3D8)d3d8_create();
|
||||
|
||||
/* this needs g_pD3D created first */
|
||||
d3d8_make_d3dpp(d3d, info, &d3dpp);
|
||||
@ -771,7 +772,7 @@ static bool d3d8_init_base(void *data, const video_info_t *info)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!d3d_create_device(&d3d->dev, &d3dpp,
|
||||
if (!d3d8_create_device(&d3d->dev, &d3dpp,
|
||||
g_pD3D8,
|
||||
focus_window,
|
||||
d3d->cur_mon_id)
|
||||
@ -920,10 +921,10 @@ static bool d3d8_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
* font objects and free/realloc them around the d3d_reset call */
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DEINIT, NULL);
|
||||
if (!d3d_reset(d3d->dev, &d3dpp))
|
||||
if (!d3d8_reset(d3d->dev, &d3dpp))
|
||||
{
|
||||
d3d8_deinitialize(d3d);
|
||||
d3d_device_free(NULL, g_pD3D8);
|
||||
d3d8_device_free(NULL, g_pD3D8);
|
||||
g_pD3D8 = NULL;
|
||||
|
||||
ret = d3d8_init_base(d3d, info);
|
||||
@ -948,11 +949,11 @@ static bool d3d8_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
|
||||
font_driver_init_osd(d3d, false,
|
||||
info->is_threaded,
|
||||
FONT_DRIVER_RENDER_DIRECT3D_API);
|
||||
FONT_DRIVER_RENDER_D3D8_API);
|
||||
|
||||
d3d->menu_display.offset = 0;
|
||||
d3d->menu_display.size = 1024;
|
||||
d3d->menu_display.buffer = d3d_vertex_buffer_new(
|
||||
d3d->menu_display.buffer = d3d8_vertex_buffer_new(
|
||||
d3d->dev, d3d->menu_display.size * sizeof(Vertex),
|
||||
D3DUSAGE_WRITEONLY,
|
||||
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
|
||||
@ -965,12 +966,12 @@ static bool d3d8_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
d3d_matrix_ortho_off_center_lh(&d3d->mvp_transposed, 0, 1, 0, 1, 0, 1);
|
||||
d3d_matrix_transpose(&d3d->mvp, &d3d->mvp_transposed);
|
||||
|
||||
d3d_set_render_state(d3d->dev, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
d3d8_set_render_state(d3d->dev, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool d3d_restore(void *data)
|
||||
static bool d3d8_restore(void *data)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
|
||||
@ -1002,13 +1003,13 @@ static void d3d8_set_nonblock_state(void *data, bool state)
|
||||
d3d->video_info.vsync = !state;
|
||||
|
||||
#ifdef _XBOX
|
||||
d3d_set_render_state(d3d->dev, D3D8_PRESENTATIONINTERVAL,
|
||||
d3d8_set_render_state(d3d->dev, D3D8_PRESENTATIONINTERVAL,
|
||||
interval ?
|
||||
D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
);
|
||||
#else
|
||||
d3d->needs_restore = true;
|
||||
d3d_restore(d3d);
|
||||
d3d8_restore(d3d);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1051,7 +1052,7 @@ static bool d3d8_alive(void *data)
|
||||
{
|
||||
d3d->should_resize = true;
|
||||
d3d8_set_resize(d3d, temp_width, temp_height);
|
||||
d3d_restore(d3d);
|
||||
d3d8_restore(d3d);
|
||||
}
|
||||
|
||||
ret = !quit;
|
||||
@ -1117,9 +1118,9 @@ static void d3d8_set_osd_msg(void *data,
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
|
||||
d3d_begin_scene(d3d->dev);
|
||||
d3d8_begin_scene(d3d->dev);
|
||||
font_driver_render_msg(video_info, font, msg, params);
|
||||
d3d_end_scene(d3d->dev);
|
||||
d3d8_end_scene(d3d->dev);
|
||||
}
|
||||
|
||||
static void d3d8_input_driver(
|
||||
@ -1273,7 +1274,7 @@ static void *d3d8_init(const video_info_t *info,
|
||||
if (!d3d)
|
||||
return NULL;
|
||||
|
||||
if (!d3d_initialize_symbols(GFX_CTX_DIRECT3D8_API))
|
||||
if (!d3d8_initialize_symbols(GFX_CTX_DIRECT3D8_API))
|
||||
{
|
||||
free(d3d);
|
||||
return NULL;
|
||||
@ -1348,11 +1349,11 @@ static void d3d8_free(void *data)
|
||||
free(d3d->shader_path);
|
||||
|
||||
d3d->shader_path = NULL;
|
||||
d3d_device_free(d3d->dev, g_pD3D8);
|
||||
d3d8_device_free(d3d->dev, g_pD3D8);
|
||||
d3d->dev = NULL;
|
||||
g_pD3D8 = NULL;
|
||||
|
||||
d3d_deinitialize_symbols();
|
||||
d3d8_deinitialize_symbols();
|
||||
|
||||
#ifndef _XBOX
|
||||
win32_monitor_from_window();
|
||||
@ -1425,10 +1426,10 @@ static bool d3d8_overlay_load(void *data,
|
||||
unsigned height = images[i].height;
|
||||
overlay_t *overlay = (overlay_t*)&d3d->overlays[i];
|
||||
|
||||
overlay->tex = d3d_texture_new(d3d->dev, NULL,
|
||||
overlay->tex = d3d8_texture_new(d3d->dev, NULL,
|
||||
width, height, 1,
|
||||
0,
|
||||
d3d_get_argb8888_format(),
|
||||
d3d8_get_argb8888_format(),
|
||||
D3DPOOL_MANAGED, 0, 0, 0,
|
||||
NULL, NULL, false);
|
||||
|
||||
@ -1438,7 +1439,7 @@ static bool d3d8_overlay_load(void *data,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (d3d_lock_rectangle(overlay->tex, 0, &d3dlr,
|
||||
if (d3d8_lock_rectangle(overlay->tex, 0, &d3dlr,
|
||||
NULL, 0, D3DLOCK_NOSYSLOCK))
|
||||
{
|
||||
uint32_t *dst = (uint32_t*)(d3dlr.pBits);
|
||||
@ -1447,7 +1448,7 @@ static bool d3d8_overlay_load(void *data,
|
||||
|
||||
for (y = 0; y < height; y++, dst += pitch, src += width)
|
||||
memcpy(dst, src, width << 2);
|
||||
d3d_unlock_rectangle(overlay->tex);
|
||||
d3d8_unlock_rectangle(overlay->tex);
|
||||
}
|
||||
|
||||
overlay->tex_w = width;
|
||||
@ -1568,7 +1569,7 @@ static bool d3d8_frame(void *data, const void *frame,
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if (!d3d_restore(d3d))
|
||||
if (!d3d8_restore(d3d))
|
||||
{
|
||||
RARCH_ERR("[D3D]: Failed to restore.\n");
|
||||
return false;
|
||||
@ -1589,8 +1590,8 @@ static bool d3d8_frame(void *data, const void *frame,
|
||||
screen_vp.MaxZ = 1;
|
||||
screen_vp.Width = width;
|
||||
screen_vp.Height = height;
|
||||
d3d_set_viewports(d3d->dev, &screen_vp);
|
||||
d3d_clear(d3d->dev, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
||||
d3d8_set_viewports(d3d->dev, &screen_vp);
|
||||
d3d8_clear(d3d->dev, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
||||
|
||||
/* Insert black frame first, so we
|
||||
* can screenshot, etc. */
|
||||
@ -1637,14 +1638,14 @@ static bool d3d8_frame(void *data, const void *frame,
|
||||
|
||||
if (!string_is_empty(msg))
|
||||
{
|
||||
d3d_set_viewports(d3d->dev, &screen_vp);
|
||||
d3d_begin_scene(d3d->dev);
|
||||
d3d8_set_viewports(d3d->dev, &screen_vp);
|
||||
d3d8_begin_scene(d3d->dev);
|
||||
font_driver_render_msg(video_info, NULL, msg, NULL);
|
||||
d3d_end_scene(d3d->dev);
|
||||
d3d8_end_scene(d3d->dev);
|
||||
}
|
||||
|
||||
d3d8_update_title(video_info);
|
||||
d3d_swap(d3d, d3d->dev);
|
||||
d3d8_swap(d3d, d3d->dev);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1679,11 +1680,11 @@ static void d3d8_set_menu_texture_frame(void *data,
|
||||
d3d->menu->tex_h != height)
|
||||
{
|
||||
if (d3d->menu)
|
||||
d3d_texture_free(d3d->menu->tex);
|
||||
d3d8_texture_free(d3d->menu->tex);
|
||||
|
||||
d3d->menu->tex = d3d_texture_new(d3d->dev, NULL,
|
||||
d3d->menu->tex = d3d8_texture_new(d3d->dev, NULL,
|
||||
width, height, 1,
|
||||
0, d3d_get_argb8888_format(),
|
||||
0, d3d8_get_argb8888_format(),
|
||||
D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL, false);
|
||||
|
||||
if (!d3d->menu->tex)
|
||||
@ -1702,7 +1703,7 @@ static void d3d8_set_menu_texture_frame(void *data,
|
||||
|
||||
d3d->menu->alpha_mod = alpha;
|
||||
|
||||
if (d3d_lock_rectangle(d3d->menu->tex, 0, &d3dlr,
|
||||
if (d3d8_lock_rectangle(d3d->menu->tex, 0, &d3dlr,
|
||||
NULL, 0, D3DLOCK_NOSYSLOCK))
|
||||
{
|
||||
unsigned h, w;
|
||||
@ -1743,7 +1744,7 @@ static void d3d8_set_menu_texture_frame(void *data,
|
||||
|
||||
|
||||
if (d3d->menu)
|
||||
d3d_unlock_rectangle(d3d->menu->tex);
|
||||
d3d8_unlock_rectangle(d3d->menu->tex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1774,9 +1775,9 @@ static void d3d8_video_texture_load_d3d(
|
||||
unsigned usage = 0;
|
||||
d3d_video_t *d3d = (d3d_video_t*)info->userdata;
|
||||
struct texture_image *ti = (struct texture_image*)info->data;
|
||||
LPDIRECT3DTEXTURE8 tex = (LPDIRECT3DTEXTURE8)d3d_texture_new(d3d->dev, NULL,
|
||||
LPDIRECT3DTEXTURE8 tex = (LPDIRECT3DTEXTURE8)d3d8_texture_new(d3d->dev, NULL,
|
||||
ti->width, ti->height, 0,
|
||||
usage, d3d_get_argb8888_format(),
|
||||
usage, d3d8_get_argb8888_format(),
|
||||
D3DPOOL_MANAGED, 0, 0, 0,
|
||||
NULL, NULL, false);
|
||||
|
||||
@ -1786,7 +1787,7 @@ static void d3d8_video_texture_load_d3d(
|
||||
return;
|
||||
}
|
||||
|
||||
if (d3d_lock_rectangle(tex, 0, &d3dlr,
|
||||
if (d3d8_lock_rectangle(tex, 0, &d3dlr,
|
||||
NULL, 0, D3DLOCK_NOSYSLOCK))
|
||||
{
|
||||
unsigned i;
|
||||
@ -1796,7 +1797,7 @@ static void d3d8_video_texture_load_d3d(
|
||||
|
||||
for (i = 0; i < ti->height; i++, dst += pitch, src += ti->width)
|
||||
memcpy(dst, src, ti->width << 2);
|
||||
d3d_unlock_rectangle(tex);
|
||||
d3d8_unlock_rectangle(tex);
|
||||
}
|
||||
|
||||
*id = (uintptr_t)tex;
|
||||
@ -1837,7 +1838,7 @@ static void d3d8_unload_texture(void *data, uintptr_t id)
|
||||
return;
|
||||
|
||||
texid = (LPDIRECT3DTEXTURE8)id;
|
||||
d3d_texture_free(texid);
|
||||
d3d8_texture_free(texid);
|
||||
}
|
||||
|
||||
static void d3d8_set_video_mode(void *data,
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "d3d.h"
|
||||
#include "../../defines/d3d_defines.h"
|
||||
#include "../common/d3d_common.h"
|
||||
#include "../common/d3d9_common.h"
|
||||
#include "../video_coord_array.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../dynamic.h"
|
||||
@ -407,7 +408,7 @@ static void d3d9_set_mvp(void *data,
|
||||
const void *mat_data)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
d3d_set_vertex_shader_constantf(d3d->dev, 0, (const float*)mat_data, 4);
|
||||
d3d9_set_vertex_shader_constantf(d3d->dev, 0, (const float*)mat_data, 4);
|
||||
}
|
||||
|
||||
static void d3d9_overlay_render(d3d_video_t *d3d,
|
||||
@ -436,7 +437,7 @@ static void d3d9_overlay_render(d3d_video_t *d3d,
|
||||
|
||||
if (!overlay->vert_buf)
|
||||
{
|
||||
overlay->vert_buf = d3d_vertex_buffer_new(
|
||||
overlay->vert_buf = d3d9_vertex_buffer_new(
|
||||
d3d->dev, sizeof(vert), D3DUSAGE_WRITEONLY,
|
||||
#ifdef _XBOX
|
||||
0,
|
||||
@ -475,18 +476,18 @@ static void d3d9_overlay_render(d3d_video_t *d3d,
|
||||
vert[2].v = overlay->tex_coords[1] + overlay->tex_coords[3];
|
||||
vert[3].v = overlay->tex_coords[1] + overlay->tex_coords[3];
|
||||
|
||||
verts = d3d_vertex_buffer_lock(overlay->vert_buf);
|
||||
verts = d3d9_vertex_buffer_lock(overlay->vert_buf);
|
||||
memcpy(verts, vert, sizeof(vert));
|
||||
d3d_vertex_buffer_unlock(overlay->vert_buf);
|
||||
d3d9_vertex_buffer_unlock(overlay->vert_buf);
|
||||
|
||||
d3d_enable_blend_func(d3d->dev);
|
||||
d3d9_enable_blend_func(d3d->dev);
|
||||
|
||||
/* set vertex declaration for overlay. */
|
||||
d3d_vertex_declaration_new(d3d->dev, &vElems, (void**)&vertex_decl);
|
||||
d3d_set_vertex_declaration(d3d->dev, vertex_decl);
|
||||
d3d_vertex_declaration_free(vertex_decl);
|
||||
d3d9_vertex_declaration_new(d3d->dev, &vElems, (void**)&vertex_decl);
|
||||
d3d9_set_vertex_declaration(d3d->dev, vertex_decl);
|
||||
d3d9_vertex_declaration_free(vertex_decl);
|
||||
|
||||
d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf,
|
||||
d3d9_set_stream_source(d3d->dev, 0, overlay->vert_buf,
|
||||
0, sizeof(*vert));
|
||||
|
||||
if (overlay->fullscreen)
|
||||
@ -499,20 +500,20 @@ static void d3d9_overlay_render(d3d_video_t *d3d,
|
||||
vp_full.Height = height;
|
||||
vp_full.MinZ = 0.0f;
|
||||
vp_full.MaxZ = 1.0f;
|
||||
d3d_set_viewports(d3d->dev, &vp_full);
|
||||
d3d9_set_viewports(d3d->dev, &vp_full);
|
||||
}
|
||||
|
||||
/* Render overlay. */
|
||||
d3d_set_texture(d3d->dev, 0, overlay->tex);
|
||||
d3d_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_LINEAR);
|
||||
d3d_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_LINEAR);
|
||||
d3d_draw_primitive(d3d->dev, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
d3d9_set_texture(d3d->dev, 0, overlay->tex);
|
||||
d3d9_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_LINEAR);
|
||||
d3d9_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_LINEAR);
|
||||
d3d9_draw_primitive(d3d->dev, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
|
||||
/* Restore previous state. */
|
||||
d3d_disable_blend_func(d3d->dev);
|
||||
d3d_set_viewports(d3d->dev, &d3d->final_viewport);
|
||||
d3d9_disable_blend_func(d3d->dev);
|
||||
d3d9_set_viewports(d3d->dev, &d3d->final_viewport);
|
||||
}
|
||||
|
||||
static void d3d9_free_overlay(d3d_video_t *d3d, overlay_t *overlay)
|
||||
@ -520,11 +521,11 @@ static void d3d9_free_overlay(d3d_video_t *d3d, overlay_t *overlay)
|
||||
if (!d3d)
|
||||
return;
|
||||
|
||||
d3d_texture_free(overlay->tex);
|
||||
d3d_vertex_buffer_free(overlay->vert_buf, NULL);
|
||||
d3d9_texture_free(overlay->tex);
|
||||
d3d9_vertex_buffer_free(overlay->vert_buf, NULL);
|
||||
}
|
||||
|
||||
static void d3d_deinit_chain(d3d_video_t *d3d)
|
||||
static void d3d9_deinit_chain(d3d_video_t *d3d)
|
||||
{
|
||||
if (!d3d || !d3d->renderchain_driver)
|
||||
return;
|
||||
@ -536,30 +537,30 @@ static void d3d_deinit_chain(d3d_video_t *d3d)
|
||||
d3d->renderchain_data = NULL;
|
||||
}
|
||||
|
||||
static void d3d_deinitialize(d3d_video_t *d3d)
|
||||
static void d3d9_deinitialize(d3d_video_t *d3d)
|
||||
{
|
||||
if (!d3d)
|
||||
return;
|
||||
|
||||
font_driver_free_osd();
|
||||
|
||||
d3d_deinit_chain(d3d);
|
||||
d3d_vertex_buffer_free(d3d->menu_display.buffer, d3d->menu_display.decl);
|
||||
d3d9_deinit_chain(d3d);
|
||||
d3d9_vertex_buffer_free(d3d->menu_display.buffer, d3d->menu_display.decl);
|
||||
d3d->menu_display.buffer = NULL;
|
||||
d3d->menu_display.decl = NULL;
|
||||
}
|
||||
|
||||
static D3DFORMAT d3d_get_color_format_backbuffer(bool rgb32, bool windowed)
|
||||
static D3DFORMAT d3d9_get_color_format_backbuffer(bool rgb32, bool windowed)
|
||||
{
|
||||
D3DFORMAT fmt = D3DFMT_X8R8G8B8;
|
||||
#ifdef _XBOX
|
||||
if (!rgb32)
|
||||
fmt = d3d_get_rgb565_format();
|
||||
fmt = d3d9_get_rgb565_format();
|
||||
#else
|
||||
if (windowed)
|
||||
{
|
||||
D3DDISPLAYMODE display_mode;
|
||||
if (d3d_get_adapter_display_mode(g_pD3D9, 0, &display_mode))
|
||||
if (d3d9_get_adapter_display_mode(g_pD3D9, 0, &display_mode))
|
||||
fmt = display_mode.Format;
|
||||
}
|
||||
#endif
|
||||
@ -567,13 +568,13 @@ static D3DFORMAT d3d_get_color_format_backbuffer(bool rgb32, bool windowed)
|
||||
}
|
||||
|
||||
#ifdef _XBOX
|
||||
static D3DFORMAT d3d_get_color_format_front_buffer(void)
|
||||
static D3DFORMAT d3d9_get_color_format_front_buffer(void)
|
||||
{
|
||||
return D3DFMT_LE_X8R8G8B8;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool d3d_is_windowed_enable(bool info_fullscreen)
|
||||
static bool d3d9_is_windowed_enable(bool info_fullscreen)
|
||||
{
|
||||
#ifndef _XBOX
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -614,7 +615,7 @@ static void d3d9_get_video_size(d3d_video_t *d3d,
|
||||
}
|
||||
#endif
|
||||
|
||||
void d3d_make_d3dpp(void *data,
|
||||
void d3d9_make_d3dpp(void *data,
|
||||
const video_info_t *info, void *_d3dpp)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
@ -625,7 +626,7 @@ void d3d_make_d3dpp(void *data,
|
||||
bool gamma_enable = global ?
|
||||
global->console.screen.gamma_correction : false;
|
||||
#endif
|
||||
bool windowed_enable = d3d_is_windowed_enable(info->fullscreen);
|
||||
bool windowed_enable = d3d9_is_windowed_enable(info->fullscreen);
|
||||
|
||||
memset(d3dpp, 0, sizeof(*d3dpp));
|
||||
|
||||
@ -656,11 +657,11 @@ void d3d_make_d3dpp(void *data,
|
||||
|
||||
d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp->BackBufferCount = 2;
|
||||
d3dpp->BackBufferFormat = d3d_get_color_format_backbuffer(
|
||||
d3dpp->BackBufferFormat = d3d9_get_color_format_backbuffer(
|
||||
info->rgb32, windowed_enable);
|
||||
|
||||
#ifdef _XBOX
|
||||
d3dpp->FrontBufferFormat = d3d_get_color_format_front_buffer();
|
||||
d3dpp->FrontBufferFormat = d3d9_get_color_format_front_buffer();
|
||||
|
||||
if (gamma_enable)
|
||||
{
|
||||
@ -706,10 +707,10 @@ static bool d3d9_init_base(void *data, const video_info_t *info)
|
||||
|
||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||
|
||||
g_pD3D9 = (LPDIRECT3D9)d3d_create();
|
||||
g_pD3D9 = (LPDIRECT3D9)d3d9_create();
|
||||
|
||||
/* this needs g_pD3D9 created first */
|
||||
d3d_make_d3dpp(d3d, info, &d3dpp);
|
||||
d3d9_make_d3dpp(d3d, info, &d3dpp);
|
||||
|
||||
if (!g_pD3D9)
|
||||
{
|
||||
@ -717,7 +718,7 @@ static bool d3d9_init_base(void *data, const video_info_t *info)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!d3d_create_device(&d3d->dev, &d3dpp,
|
||||
if (!d3d9_create_device(&d3d->dev, &d3dpp,
|
||||
g_pD3D9,
|
||||
focus_window,
|
||||
d3d->cur_mon_id)
|
||||
@ -730,7 +731,7 @@ static bool d3d9_init_base(void *data, const video_info_t *info)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void d3d_calculate_rect(void *data,
|
||||
static void d3d9_calculate_rect(void *data,
|
||||
unsigned *width, unsigned *height,
|
||||
int *x, int *y,
|
||||
bool force_full,
|
||||
@ -818,7 +819,7 @@ static void d3d9_set_viewport(void *data,
|
||||
int y = 0;
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
|
||||
d3d_calculate_rect(data, &width, &height, &x, &y,
|
||||
d3d9_calculate_rect(data, &width, &height, &x, &y,
|
||||
force_full, allow_rotate);
|
||||
|
||||
/* D3D doesn't support negative X/Y viewports ... */
|
||||
@ -853,7 +854,7 @@ static bool d3d9_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
{
|
||||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
|
||||
d3d_make_d3dpp(d3d, info, &d3dpp);
|
||||
d3d9_make_d3dpp(d3d, info, &d3dpp);
|
||||
|
||||
/* the D3DX font driver uses POOL_DEFAULT resources
|
||||
* and will prevent a clean reset here
|
||||
@ -861,10 +862,10 @@ static bool d3d9_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
* font objects and free/realloc them around the d3d_reset call */
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DEINIT, NULL);
|
||||
if (!d3d_reset(d3d->dev, &d3dpp))
|
||||
if (!d3d9_reset(d3d->dev, &d3dpp))
|
||||
{
|
||||
d3d_deinitialize(d3d);
|
||||
d3d_device_free(NULL, g_pD3D9);
|
||||
d3d9_deinitialize(d3d);
|
||||
d3d9_device_free(NULL, g_pD3D9);
|
||||
g_pD3D9 = NULL;
|
||||
|
||||
ret = d3d9_init_base(d3d, info);
|
||||
@ -893,7 +894,7 @@ static bool d3d9_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
#endif
|
||||
font_driver_init_osd(d3d, false,
|
||||
info->is_threaded,
|
||||
FONT_DRIVER_RENDER_DIRECT3D_API);
|
||||
FONT_DRIVER_RENDER_D3D9_API);
|
||||
|
||||
{
|
||||
static const D3DVERTEXELEMENT9 VertexElements[4] = {
|
||||
@ -905,14 +906,14 @@ static bool d3d9_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
D3DDECLUSAGE_COLOR, 0},
|
||||
D3DDECL_END()
|
||||
};
|
||||
if (!d3d_vertex_declaration_new(d3d->dev,
|
||||
if (!d3d9_vertex_declaration_new(d3d->dev,
|
||||
(void*)VertexElements, (void**)&d3d->menu_display.decl))
|
||||
return false;
|
||||
}
|
||||
|
||||
d3d->menu_display.offset = 0;
|
||||
d3d->menu_display.size = 1024;
|
||||
d3d->menu_display.buffer = d3d_vertex_buffer_new(
|
||||
d3d->menu_display.buffer = d3d9_vertex_buffer_new(
|
||||
d3d->dev, d3d->menu_display.size * sizeof(Vertex),
|
||||
D3DUSAGE_WRITEONLY,
|
||||
#ifdef _XBOX
|
||||
@ -929,7 +930,7 @@ static bool d3d9_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
d3d_matrix_ortho_off_center_lh(&d3d->mvp_transposed, 0, 1, 0, 1, 0, 1);
|
||||
d3d_matrix_transpose(&d3d->mvp, &d3d->mvp_transposed);
|
||||
|
||||
d3d_set_render_state(d3d->dev, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
d3d9_set_render_state(d3d->dev, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -941,7 +942,7 @@ static bool d3d9_restore(void *data)
|
||||
if (!d3d)
|
||||
return false;
|
||||
|
||||
d3d_deinitialize(d3d);
|
||||
d3d9_deinitialize(d3d);
|
||||
|
||||
if (!d3d9_initialize(d3d, &d3d->video_info))
|
||||
{
|
||||
@ -966,7 +967,7 @@ static void d3d9_set_nonblock_state(void *data, bool state)
|
||||
d3d->video_info.vsync = !state;
|
||||
|
||||
#ifdef _XBOX
|
||||
d3d_set_render_state(d3d->dev,
|
||||
d3d9_set_render_state(d3d->dev,
|
||||
D3D9_PRESENTATIONINTERVAL,
|
||||
interval ?
|
||||
D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE
|
||||
@ -1070,9 +1071,9 @@ static void d3d9_set_osd_msg(void *data,
|
||||
if (d3d->renderchain_driver->set_font_rect && params)
|
||||
d3d->renderchain_driver->set_font_rect(d3d, params);
|
||||
|
||||
d3d_begin_scene(d3d->dev);
|
||||
d3d9_begin_scene(d3d->dev);
|
||||
font_driver_render_msg(video_info, font, msg, params);
|
||||
d3d_end_scene(d3d->dev);
|
||||
d3d9_end_scene(d3d->dev);
|
||||
}
|
||||
|
||||
static void d3d9_input_driver(
|
||||
@ -1251,7 +1252,7 @@ static void *d3d9_init(const video_info_t *info,
|
||||
if (!d3d)
|
||||
return NULL;
|
||||
|
||||
if (!d3d_initialize_symbols(GFX_CTX_DIRECT3D9_API))
|
||||
if (!d3d9_initialize_symbols(GFX_CTX_DIRECT3D9_API))
|
||||
{
|
||||
free(d3d);
|
||||
return NULL;
|
||||
@ -1320,17 +1321,17 @@ static void d3d9_free(void *data)
|
||||
free(d3d->menu);
|
||||
d3d->menu = NULL;
|
||||
|
||||
d3d_deinitialize(d3d);
|
||||
d3d9_deinitialize(d3d);
|
||||
|
||||
if (!string_is_empty(d3d->shader_path))
|
||||
free(d3d->shader_path);
|
||||
|
||||
d3d->shader_path = NULL;
|
||||
d3d_device_free(d3d->dev, g_pD3D9);
|
||||
d3d9_device_free(d3d->dev, g_pD3D9);
|
||||
d3d->dev = NULL;
|
||||
g_pD3D9 = NULL;
|
||||
|
||||
d3d_deinitialize_symbols();
|
||||
d3d9_deinitialize_symbols();
|
||||
|
||||
#ifndef _XBOX
|
||||
win32_monitor_from_window();
|
||||
@ -1397,10 +1398,10 @@ static bool d3d9_overlay_load(void *data,
|
||||
unsigned height = images[i].height;
|
||||
overlay_t *overlay = (overlay_t*)&d3d->overlays[i];
|
||||
|
||||
overlay->tex = d3d_texture_new(d3d->dev, NULL,
|
||||
overlay->tex = d3d9_texture_new(d3d->dev, NULL,
|
||||
width, height, 1,
|
||||
0,
|
||||
d3d_get_argb8888_format(),
|
||||
d3d9_get_argb8888_format(),
|
||||
D3DPOOL_MANAGED, 0, 0, 0,
|
||||
NULL, NULL, false);
|
||||
|
||||
@ -1410,7 +1411,7 @@ static bool d3d9_overlay_load(void *data,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (d3d_lock_rectangle(overlay->tex, 0, &d3dlr,
|
||||
if (d3d9_lock_rectangle(overlay->tex, 0, &d3dlr,
|
||||
NULL, 0, D3DLOCK_NOSYSLOCK))
|
||||
{
|
||||
uint32_t *dst = (uint32_t*)(d3dlr.pBits);
|
||||
@ -1419,7 +1420,7 @@ static bool d3d9_overlay_load(void *data,
|
||||
|
||||
for (y = 0; y < height; y++, dst += pitch, src += width)
|
||||
memcpy(dst, src, width << 2);
|
||||
d3d_unlock_rectangle(overlay->tex);
|
||||
d3d9_unlock_rectangle(overlay->tex);
|
||||
}
|
||||
|
||||
overlay->tex_w = width;
|
||||
@ -1565,16 +1566,16 @@ static bool d3d9_frame(void *data, const void *frame,
|
||||
screen_vp.MaxZ = 1;
|
||||
screen_vp.Width = width;
|
||||
screen_vp.Height = height;
|
||||
d3d_set_viewports(d3d->dev, &screen_vp);
|
||||
d3d_clear(d3d->dev, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
||||
d3d9_set_viewports(d3d->dev, &screen_vp);
|
||||
d3d9_clear(d3d->dev, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
||||
|
||||
/* Insert black frame first, so we
|
||||
* can screenshot, etc. */
|
||||
if (video_info->black_frame_insertion)
|
||||
{
|
||||
if (!d3d_swap(d3d, d3d->dev) || d3d->needs_restore)
|
||||
if (!d3d9_swap(d3d, d3d->dev) || d3d->needs_restore)
|
||||
return true;
|
||||
d3d_clear(d3d->dev, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
||||
d3d9_clear(d3d->dev, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
||||
}
|
||||
|
||||
if (!d3d->renderchain_driver->render(
|
||||
@ -1594,10 +1595,10 @@ static bool d3d9_frame(void *data, const void *frame,
|
||||
d3d9_overlay_render(d3d, video_info, d3d->menu);
|
||||
|
||||
d3d->menu_display.offset = 0;
|
||||
d3d_set_vertex_declaration(d3d->dev, d3d->menu_display.decl);
|
||||
d3d_set_stream_source(d3d->dev, 0, d3d->menu_display.buffer, 0, sizeof(Vertex));
|
||||
d3d9_set_vertex_declaration(d3d->dev, d3d->menu_display.decl);
|
||||
d3d9_set_stream_source(d3d->dev, 0, d3d->menu_display.buffer, 0, sizeof(Vertex));
|
||||
|
||||
d3d_set_viewports(d3d->dev, &screen_vp);
|
||||
d3d9_set_viewports(d3d->dev, &screen_vp);
|
||||
menu_driver_frame(video_info);
|
||||
}
|
||||
#endif
|
||||
@ -1613,14 +1614,14 @@ static bool d3d9_frame(void *data, const void *frame,
|
||||
|
||||
if (msg && *msg)
|
||||
{
|
||||
d3d_set_viewports(d3d->dev, &screen_vp);
|
||||
d3d_begin_scene(d3d->dev);
|
||||
d3d9_set_viewports(d3d->dev, &screen_vp);
|
||||
d3d9_begin_scene(d3d->dev);
|
||||
font_driver_render_msg(video_info, NULL, msg, NULL);
|
||||
d3d_end_scene(d3d->dev);
|
||||
d3d9_end_scene(d3d->dev);
|
||||
}
|
||||
|
||||
d3d9_update_title(video_info);
|
||||
d3d_swap(d3d, d3d->dev);
|
||||
d3d9_swap(d3d, d3d->dev);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1693,11 +1694,11 @@ static void d3d9_set_menu_texture_frame(void *data,
|
||||
d3d->menu->tex_h != height)
|
||||
{
|
||||
if (d3d->menu)
|
||||
d3d_texture_free(d3d->menu->tex);
|
||||
d3d9_texture_free(d3d->menu->tex);
|
||||
|
||||
d3d->menu->tex = d3d_texture_new(d3d->dev, NULL,
|
||||
d3d->menu->tex = d3d9_texture_new(d3d->dev, NULL,
|
||||
width, height, 1,
|
||||
0, d3d_get_argb8888_format(),
|
||||
0, d3d9_get_argb8888_format(),
|
||||
D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL, false);
|
||||
|
||||
if (!d3d->menu->tex)
|
||||
@ -1712,7 +1713,7 @@ static void d3d9_set_menu_texture_frame(void *data,
|
||||
|
||||
d3d->menu->alpha_mod = alpha;
|
||||
|
||||
if (d3d_lock_rectangle(d3d->menu->tex, 0, &d3dlr,
|
||||
if (d3d9_lock_rectangle(d3d->menu->tex, 0, &d3dlr,
|
||||
NULL, 0, D3DLOCK_NOSYSLOCK))
|
||||
{
|
||||
unsigned h, w;
|
||||
@ -1753,7 +1754,7 @@ static void d3d9_set_menu_texture_frame(void *data,
|
||||
|
||||
|
||||
if (d3d->menu)
|
||||
d3d_unlock_rectangle(d3d->menu->tex);
|
||||
d3d9_unlock_rectangle(d3d->menu->tex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1794,9 +1795,9 @@ static void d3d9_video_texture_load_d3d(
|
||||
(info->type == TEXTURE_FILTER_MIPMAP_NEAREST))
|
||||
want_mipmap = true;
|
||||
|
||||
tex = (LPDIRECT3DTEXTURE9)d3d_texture_new(d3d->dev, NULL,
|
||||
tex = (LPDIRECT3DTEXTURE9)d3d9_texture_new(d3d->dev, NULL,
|
||||
ti->width, ti->height, 0,
|
||||
usage, d3d_get_argb8888_format(),
|
||||
usage, d3d9_get_argb8888_format(),
|
||||
D3DPOOL_MANAGED, 0, 0, 0,
|
||||
NULL, NULL, want_mipmap);
|
||||
|
||||
@ -1806,7 +1807,7 @@ static void d3d9_video_texture_load_d3d(
|
||||
return;
|
||||
}
|
||||
|
||||
if (d3d_lock_rectangle(tex, 0, &d3dlr,
|
||||
if (d3d9_lock_rectangle(tex, 0, &d3dlr,
|
||||
NULL, 0, D3DLOCK_NOSYSLOCK))
|
||||
{
|
||||
unsigned i;
|
||||
@ -1816,7 +1817,7 @@ static void d3d9_video_texture_load_d3d(
|
||||
|
||||
for (i = 0; i < ti->height; i++, dst += pitch, src += ti->width)
|
||||
memcpy(dst, src, ti->width << 2);
|
||||
d3d_unlock_rectangle(tex);
|
||||
d3d9_unlock_rectangle(tex);
|
||||
}
|
||||
|
||||
*id = (uintptr_t)tex;
|
||||
@ -1857,7 +1858,7 @@ static void d3d9_unload_texture(void *data, uintptr_t id)
|
||||
return;
|
||||
|
||||
texid = (LPDIRECT3DTEXTURE9)id;
|
||||
d3d_texture_free(texid);
|
||||
d3d9_texture_free(texid);
|
||||
}
|
||||
|
||||
static void d3d9_set_video_mode(void *data,
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "../drivers/d3d.h"
|
||||
#include "../common/d3d_common.h"
|
||||
#include "../common/d3d9_common.h"
|
||||
#include "../font_driver.h"
|
||||
|
||||
#include "../../configuration.h"
|
||||
@ -81,12 +82,12 @@ static void *d3dfonts_w32_init_font(void *video_data,
|
||||
|
||||
desc.Height = d3dfonts->font_size;
|
||||
|
||||
if (!d3dx_create_font_indirect(d3dfonts->d3d->dev,
|
||||
if (!d3d9x_create_font_indirect(d3dfonts->d3d->dev,
|
||||
&desc, (void**)&d3dfonts->font))
|
||||
goto error;
|
||||
|
||||
|
||||
d3dx_font_get_text_metrics(d3dfonts->font, &metrics);
|
||||
d3d9x_font_get_text_metrics(d3dfonts->font, &metrics);
|
||||
|
||||
d3dfonts->ascent = metrics.tmAscent;
|
||||
|
||||
@ -105,7 +106,7 @@ static void d3dfonts_w32_free_font(void *data, bool is_threaded)
|
||||
return;
|
||||
|
||||
if (d3dfonts->font)
|
||||
d3dx_font_release(d3dfonts->font);
|
||||
d3d9x_font_release(d3dfonts->font);
|
||||
|
||||
free(d3dfonts);
|
||||
}
|
||||
@ -120,7 +121,7 @@ static int d3dfonts_w32_get_message_width(void* data, const char* msg,
|
||||
if (!d3dfonts || !msg)
|
||||
return 0;
|
||||
|
||||
d3dx_font_draw_text(d3dfonts->font, NULL, (void*)msg,
|
||||
d3d9x_font_draw_text(d3dfonts->font, NULL, (void*)msg,
|
||||
msg_len? msg_len : -1, &box, DT_CALCRECT, 0);
|
||||
|
||||
return box.right - box.left;
|
||||
@ -213,12 +214,12 @@ static void d3dfonts_w32_render_msg(video_frame_info_t *video_info,
|
||||
unsigned drop_g = g * drop_mod;
|
||||
unsigned drop_b = b * drop_mod;
|
||||
|
||||
d3dx_font_draw_text(d3dfonts->font, NULL,
|
||||
d3d9x_font_draw_text(d3dfonts->font, NULL,
|
||||
(void*)msg, -1, p_rect_shifted, format,
|
||||
D3DCOLOR_ARGB(drop_a , drop_r, drop_g, drop_b));
|
||||
}
|
||||
|
||||
d3dx_font_draw_text(d3dfonts->font, NULL, (void*)msg, -1,
|
||||
d3d9x_font_draw_text(d3dfonts->font, NULL, (void*)msg, -1,
|
||||
p_rect, format, D3DCOLOR_ARGB(a, r, g, b));
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
#endif
|
||||
|
||||
#include "../drivers/d3d.h"
|
||||
#include "../drivers/d3d_common.h"
|
||||
#include "../drivers/d3d8_common.h"
|
||||
|
||||
#include "../font_driver.h"
|
||||
|
||||
@ -96,7 +98,7 @@ static void xfonts_render_msg(
|
||||
y = video_info->font_msg_pos_y;
|
||||
}
|
||||
|
||||
d3d_device_get_backbuffer(xfonts->d3d->dev, -1, 0, D3DBACKBUFFER_TYPE_MONO, &xfonts->surf);
|
||||
d3d8_device_get_backbuffer(xfonts->d3d->dev, -1, 0, D3DBACKBUFFER_TYPE_MONO, &xfonts->surf);
|
||||
|
||||
mbstowcs(str, msg, sizeof(str) / sizeof(wchar_t));
|
||||
|
||||
@ -105,7 +107,7 @@ static void xfonts_render_msg(
|
||||
#else
|
||||
XFONT_TextOut(xfonts->debug_font, xfonts->surf, str, (unsigned)-1, x, y);
|
||||
#endif
|
||||
d3d_surface_free(xfonts->surf);
|
||||
d3d8_surface_free(xfonts->surf);
|
||||
}
|
||||
|
||||
font_renderer_t d3d_xdk1_font = {
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "../drivers/d3d.h"
|
||||
#include "../common/d3d_common.h"
|
||||
#include "../common/d3d9_common.h"
|
||||
#include "../font_driver.h"
|
||||
|
||||
#include "../drivers/d3d_shaders/font.hlsl.d3d9.h"
|
||||
@ -439,14 +440,14 @@ static bool xdk360_video_font_create_shaders(xdk360_video_font_t * font, void *d
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!d3d_vertex_declaration_new(dev, decl, (void**)&font->s_FontLocals.m_pFontVertexDecl))
|
||||
if (!d3d9_vertex_declaration_new(dev, decl, (void**)&font->s_FontLocals.m_pFontVertexDecl))
|
||||
goto error;
|
||||
|
||||
if (!d3dx_compile_shader( font_hlsl_d3d9_program, sizeof(font_hlsl_d3d9_program)-1 ,
|
||||
NULL, NULL, "main_vertex", "vs.2.0", 0, &pShaderCode, NULL, NULL ))
|
||||
goto error;
|
||||
|
||||
if (!d3d_create_vertex_shader(dev, (const DWORD*)pShaderCode->GetBufferPointer(),
|
||||
if (!d3d9_create_vertex_shader(dev, (const DWORD*)pShaderCode->GetBufferPointer(),
|
||||
(void**)&font->s_FontLocals.m_pFontVertexShader ))
|
||||
goto error;
|
||||
|
||||
@ -456,7 +457,7 @@ static bool xdk360_video_font_create_shaders(xdk360_video_font_t * font, void *d
|
||||
NULL, NULL, "main_fragment", "ps.2.0", 0,&pShaderCode, NULL, NULL ))
|
||||
goto error;
|
||||
|
||||
if (!d3d_create_pixel_shader(dev, (DWORD*)pShaderCode->GetBufferPointer(),
|
||||
if (!d3d9_create_pixel_shader(dev, (DWORD*)pShaderCode->GetBufferPointer(),
|
||||
(void**)&font->s_FontLocals.m_pFontPixelShader))
|
||||
goto error;
|
||||
|
||||
@ -467,9 +468,9 @@ static bool xdk360_video_font_create_shaders(xdk360_video_font_t * font, void *d
|
||||
error:
|
||||
if (pShaderCode)
|
||||
d3dxbuffer_release(pShaderCode);
|
||||
d3d_free_pixel_shader(font->d3d->dev, font->s_FontLocals.m_pFontPixelShader);
|
||||
d3d_free_vertex_shader(font->d3d->dev, font->s_FontLocals.m_pFontVertexShader);
|
||||
d3d_vertex_declaration_free(font->s_FontLocals.m_pFontVertexDecl);
|
||||
d3d9_free_pixel_shader(font->d3d->dev, font->s_FontLocals.m_pFontPixelShader);
|
||||
d3d9_free_vertex_shader(font->d3d->dev, font->s_FontLocals.m_pFontVertexShader);
|
||||
d3d9_vertex_declaration_free(font->s_FontLocals.m_pFontVertexDecl);
|
||||
font->s_FontLocals.m_pFontPixelShader = NULL;
|
||||
font->s_FontLocals.m_pFontVertexShader = NULL;
|
||||
font->s_FontLocals.m_pFontVertexDecl = NULL;
|
||||
@ -565,9 +566,9 @@ static void xdk360_free_font(void *data, bool is_threaded)
|
||||
font->m_cMaxGlyph = 0;
|
||||
font->m_TranslatorTable = NULL;
|
||||
|
||||
d3d_free_pixel_shader(font->d3d->dev, font->s_FontLocals.m_pFontPixelShader);
|
||||
d3d_free_vertex_shader(font->d3d->dev, font->s_FontLocals.m_pFontVertexShader);
|
||||
d3d_vertex_declaration_free(font->s_FontLocals.m_pFontVertexDecl);
|
||||
d3d9_free_pixel_shader(font->d3d->dev, font->s_FontLocals.m_pFontPixelShader);
|
||||
d3d9_free_vertex_shader(font->d3d->dev, font->s_FontLocals.m_pFontVertexShader);
|
||||
d3d9_vertex_declaration_free(font->s_FontLocals.m_pFontVertexDecl);
|
||||
|
||||
font->s_FontLocals.m_pFontPixelShader = NULL;
|
||||
font->s_FontLocals.m_pFontVertexShader = NULL;
|
||||
@ -585,11 +586,11 @@ static void xdk360_render_msg_post(xdk360_video_font_t * font)
|
||||
if (!font || !font->d3d || !font->d3d->dev)
|
||||
return;
|
||||
|
||||
d3d_set_texture(font->d3d->dev, 0, NULL);
|
||||
d3d_set_vertex_declaration(font->d3d->dev, NULL);
|
||||
d3d_set_vertex_shader(font->d3d->dev, 0, NULL);
|
||||
d3d_set_pixel_shader(font->d3d->dev, NULL);
|
||||
d3d_set_render_state(font->d3d->dev, D3DRS_VIEWPORTENABLE, font->m_dwSavedState);
|
||||
d3d9_set_texture(font->d3d->dev, 0, NULL);
|
||||
d3d9_set_vertex_declaration(font->d3d->dev, NULL);
|
||||
d3d9_set_vertex_shader(font->d3d->dev, 0, NULL);
|
||||
d3d9_set_pixel_shader(font->d3d->dev, NULL);
|
||||
d3d9_set_render_state(font->d3d->dev, D3DRS_VIEWPORTENABLE, font->m_dwSavedState);
|
||||
}
|
||||
|
||||
static void xdk360_render_msg_pre(xdk360_video_font_t * font)
|
||||
@ -601,26 +602,26 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font)
|
||||
return;
|
||||
|
||||
/* Save state. */
|
||||
d3d_get_render_state(font->d3d->dev, D3DRS_VIEWPORTENABLE,
|
||||
d3d9_get_render_state(font->d3d->dev, D3DRS_VIEWPORTENABLE,
|
||||
(DWORD*)&font->m_dwSavedState );
|
||||
|
||||
/* Set the texture scaling factor as a vertex shader constant. */
|
||||
/* Get the description */
|
||||
d3d_texture_get_level_desc(font->m_pFontTexture, 0, &TextureDesc);
|
||||
d3d9_texture_get_level_desc(font->m_pFontTexture, 0, &TextureDesc);
|
||||
|
||||
/* Set render state. */
|
||||
d3d_set_texture(font->d3d->dev, 0, font->m_pFontTexture);
|
||||
d3d9_set_texture(font->d3d->dev, 0, font->m_pFontTexture);
|
||||
|
||||
vTexScale[0] = 1.0f / TextureDesc.Width;
|
||||
vTexScale[1] = 1.0f / TextureDesc.Height;
|
||||
vTexScale[2] = 0.0f;
|
||||
vTexScale[3] = 0.0f;
|
||||
|
||||
d3d_set_render_state(font->d3d->dev, D3DRS_VIEWPORTENABLE, FALSE);
|
||||
d3d_set_vertex_declaration(font->d3d->dev, font->s_FontLocals.m_pFontVertexDecl);
|
||||
d3d_set_vertex_shader(font->d3d->dev, 0, font->s_FontLocals.m_pFontVertexShader);
|
||||
d3d_set_pixel_shader(font->d3d->dev, font->s_FontLocals.m_pFontPixelShader);
|
||||
d3d_set_vertex_shader_constantf(font->d3d->dev, 2, vTexScale, 1);
|
||||
d3d9_set_render_state(font->d3d->dev, D3DRS_VIEWPORTENABLE, FALSE);
|
||||
d3d9_set_vertex_declaration(font->d3d->dev, font->s_FontLocals.m_pFontVertexDecl);
|
||||
d3d9_set_vertex_shader(font->d3d->dev, 0, font->s_FontLocals.m_pFontVertexShader);
|
||||
d3d9_set_pixel_shader(font->d3d->dev, font->s_FontLocals.m_pFontPixelShader);
|
||||
d3d9_set_vertex_shader_constantf(font->d3d->dev, 2, vTexScale, 1);
|
||||
}
|
||||
|
||||
static void xdk360_draw_text(xdk360_video_font_t *font,
|
||||
@ -637,7 +638,7 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
|
||||
vColor[2] = ((0xffffffff & 0x000000ff) >> 0L) / 255.0f;
|
||||
vColor[3] = ((0xffffffff & 0xff000000) >> 24L) / 255.0f;
|
||||
|
||||
d3d_set_vertex_shader_constantf(dev, 1, vColor, 1);
|
||||
d3d9_set_vertex_shader_constantf(dev, 1, vColor, 1);
|
||||
|
||||
m_fCursorX = floorf(x);
|
||||
m_fCursorY = floorf(y);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "../common/d3d_common.h"
|
||||
#include "../common/d3d9_common.h"
|
||||
#include "../drivers/d3d.h"
|
||||
#include "../drivers/d3d_shaders/opaque.cg.d3d9.h"
|
||||
|
||||
@ -434,7 +435,7 @@ static bool d3d9_cg_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||
|
||||
free(indices);
|
||||
|
||||
return d3d_vertex_declaration_new(chain->dev,
|
||||
return d3d9_vertex_declaration_new(chain->dev,
|
||||
decl, (void**)&pass->vertex_decl);
|
||||
}
|
||||
|
||||
@ -460,13 +461,13 @@ static void d3d9_cg_renderchain_bind_orig(cg_renderchain_t *chain,
|
||||
if (param)
|
||||
{
|
||||
index = cgGetParameterResourceIndex(param);
|
||||
d3d_set_texture(chain->dev, index, chain->passes->data[0].tex);
|
||||
d3d_set_sampler_magfilter(chain->dev, index,
|
||||
d3d_translate_filter(chain->passes->data[0].info.pass->filter));
|
||||
d3d_set_sampler_minfilter(chain->dev, index,
|
||||
d3d_translate_filter(chain->passes->data[0].info.pass->filter));
|
||||
d3d_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d9_set_texture(chain->dev, index, chain->passes->data[0].tex);
|
||||
d3d9_set_sampler_magfilter(chain->dev, index,
|
||||
d3d9_translate_filter(chain->passes->data[0].info.pass->filter));
|
||||
d3d9_set_sampler_minfilter(chain->dev, index,
|
||||
d3d9_translate_filter(chain->passes->data[0].info.pass->filter));
|
||||
d3d9_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
unsigned_vector_list_append(chain->bound_tex, index);
|
||||
}
|
||||
|
||||
@ -477,7 +478,7 @@ static void d3d9_cg_renderchain_bind_orig(cg_renderchain_t *chain,
|
||||
|
||||
index = pass->attrib_map->data[cgGetParameterResourceIndex(param)];
|
||||
|
||||
d3d_set_stream_source(chain->dev, index,
|
||||
d3d9_set_stream_source(chain->dev, index,
|
||||
vert_buf, 0, sizeof(struct CGVertex));
|
||||
unsigned_vector_list_append(chain->bound_vert, index);
|
||||
}
|
||||
@ -534,15 +535,15 @@ static void d3d9_cg_renderchain_bind_prev(void *data, const void *pass_data)
|
||||
tex = (LPDIRECT3DTEXTURE9)
|
||||
chain->prev.tex[(chain->prev.ptr - (i + 1)) & TEXTURESMASK];
|
||||
|
||||
d3d_set_texture(chain->dev, index, tex);
|
||||
d3d9_set_texture(chain->dev, index, tex);
|
||||
unsigned_vector_list_append(chain->bound_tex, index);
|
||||
|
||||
d3d_set_sampler_magfilter(chain->dev, index,
|
||||
d3d_translate_filter(chain->passes->data[0].info.pass->filter));
|
||||
d3d_set_sampler_minfilter(chain->dev, index,
|
||||
d3d_translate_filter(chain->passes->data[0].info.pass->filter));
|
||||
d3d_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_magfilter(chain->dev, index,
|
||||
d3d9_translate_filter(chain->passes->data[0].info.pass->filter));
|
||||
d3d9_set_sampler_minfilter(chain->dev, index,
|
||||
d3d9_translate_filter(chain->passes->data[0].info.pass->filter));
|
||||
d3d9_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
}
|
||||
|
||||
param = cgGetNamedParameter(pass->vPrg, attr_coord);
|
||||
@ -553,7 +554,7 @@ static void d3d9_cg_renderchain_bind_prev(void *data, const void *pass_data)
|
||||
|
||||
index = pass->attrib_map->data[cgGetParameterResourceIndex(param)];
|
||||
|
||||
d3d_set_stream_source(chain->dev, index,
|
||||
d3d9_set_stream_source(chain->dev, index,
|
||||
vert_buf, 0, sizeof(struct CGVertex));
|
||||
unsigned_vector_list_append(chain->bound_vert, index);
|
||||
}
|
||||
@ -567,13 +568,13 @@ static void d3d9_cg_renderchain_add_lut_internal(void *data,
|
||||
if (!chain)
|
||||
return;
|
||||
|
||||
d3d_set_texture(chain->dev, index, chain->luts->data[i].tex);
|
||||
d3d_set_sampler_magfilter(chain->dev, index,
|
||||
d3d_translate_filter(chain->luts->data[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST));
|
||||
d3d_set_sampler_minfilter(chain->dev, index,
|
||||
d3d_translate_filter(chain->luts->data[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST));
|
||||
d3d_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d9_set_texture(chain->dev, index, chain->luts->data[i].tex);
|
||||
d3d9_set_sampler_magfilter(chain->dev, index,
|
||||
d3d9_translate_filter(chain->luts->data[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST));
|
||||
d3d9_set_sampler_minfilter(chain->dev, index,
|
||||
d3d9_translate_filter(chain->luts->data[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST));
|
||||
d3d9_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
unsigned_vector_list_append(chain->bound_tex, index);
|
||||
}
|
||||
|
||||
@ -620,13 +621,13 @@ static void d3d9_cg_renderchain_bind_pass(
|
||||
index = cgGetParameterResourceIndex(param);
|
||||
unsigned_vector_list_append(chain->bound_tex, index);
|
||||
|
||||
d3d_set_texture(chain->dev, index, chain->passes->data[i].tex);
|
||||
d3d_set_sampler_magfilter(chain->dev, index,
|
||||
d3d_translate_filter(chain->passes->data[i].info.pass->filter));
|
||||
d3d_set_sampler_minfilter(chain->dev, index,
|
||||
d3d_translate_filter(chain->passes->data[i].info.pass->filter));
|
||||
d3d_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d9_set_texture(chain->dev, index, chain->passes->data[i].tex);
|
||||
d3d9_set_sampler_magfilter(chain->dev, index,
|
||||
d3d9_translate_filter(chain->passes->data[i].info.pass->filter));
|
||||
d3d9_set_sampler_minfilter(chain->dev, index,
|
||||
d3d9_translate_filter(chain->passes->data[i].info.pass->filter));
|
||||
d3d9_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
|
||||
}
|
||||
|
||||
param = cgGetNamedParameter(pass->vPrg, attr_coord);
|
||||
@ -634,7 +635,7 @@ static void d3d9_cg_renderchain_bind_pass(
|
||||
{
|
||||
index = pass->attrib_map->data[cgGetParameterResourceIndex(param)];
|
||||
|
||||
d3d_set_stream_source(chain->dev, index, chain->passes->data[i].vertex_buf,
|
||||
d3d9_set_stream_source(chain->dev, index, chain->passes->data[i].vertex_buf,
|
||||
0, sizeof(struct CGVertex));
|
||||
unsigned_vector_list_append(chain->bound_vert, index);
|
||||
}
|
||||
@ -653,14 +654,14 @@ static void d3d9_cg_deinit_progs(void *data)
|
||||
|
||||
if (cg_data->passes->count >= 1)
|
||||
{
|
||||
d3d_vertex_buffer_free(NULL, cg_data->passes->data[0].vertex_decl);
|
||||
d3d9_vertex_buffer_free(NULL, cg_data->passes->data[0].vertex_decl);
|
||||
|
||||
for (i = 1; i < cg_data->passes->count; i++)
|
||||
{
|
||||
if (cg_data->passes->data[i].tex)
|
||||
d3d_texture_free(cg_data->passes->data[i].tex);
|
||||
d3d9_texture_free(cg_data->passes->data[i].tex);
|
||||
cg_data->passes->data[i].tex = NULL;
|
||||
d3d_vertex_buffer_free(
|
||||
d3d9_vertex_buffer_free(
|
||||
cg_data->passes->data[i].vertex_buf,
|
||||
cg_data->passes->data[i].vertex_decl);
|
||||
|
||||
@ -685,9 +686,9 @@ static void d3d9_cg_destroy_resources(void *data)
|
||||
for (i = 0; i < TEXTURES; i++)
|
||||
{
|
||||
if (cg_data->prev.tex[i])
|
||||
d3d_texture_free(cg_data->prev.tex[i]);
|
||||
d3d9_texture_free(cg_data->prev.tex[i]);
|
||||
if (cg_data->prev.vertex_buf[i])
|
||||
d3d_vertex_buffer_free(cg_data->prev.vertex_buf[i], NULL);
|
||||
d3d9_vertex_buffer_free(cg_data->prev.vertex_buf[i], NULL);
|
||||
}
|
||||
|
||||
d3d9_cg_deinit_progs(cg_data);
|
||||
@ -695,7 +696,7 @@ static void d3d9_cg_destroy_resources(void *data)
|
||||
for (i = 0; i < cg_data->luts->count; i++)
|
||||
{
|
||||
if (cg_data->luts->data[i].tex)
|
||||
d3d_texture_free(cg_data->luts->data[i].tex);
|
||||
d3d9_texture_free(cg_data->luts->data[i].tex);
|
||||
}
|
||||
|
||||
if (cg_data->state_tracker)
|
||||
@ -852,8 +853,8 @@ static bool d3d9_cg_renderchain_create_first_pass(
|
||||
|
||||
d3d_matrix_identity(&ident);
|
||||
|
||||
d3d_set_transform(chain->dev, D3DTS_WORLD, &ident);
|
||||
d3d_set_transform(chain->dev, D3DTS_VIEW, &ident);
|
||||
d3d9_set_transform(chain->dev, D3DTS_WORLD, &ident);
|
||||
d3d9_set_transform(chain->dev, D3DTS_VIEW, &ident);
|
||||
|
||||
pass.info = *info;
|
||||
pass.last_width = 0;
|
||||
@ -867,7 +868,7 @@ static bool d3d9_cg_renderchain_create_first_pass(
|
||||
chain->prev.last_width[i] = 0;
|
||||
chain->prev.last_height[i] = 0;
|
||||
chain->prev.vertex_buf[i] = (LPDIRECT3DVERTEXBUFFER9)
|
||||
d3d_vertex_buffer_new(
|
||||
d3d9_vertex_buffer_new(
|
||||
chain->dev, 4 * sizeof(struct CGVertex),
|
||||
D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, NULL);
|
||||
|
||||
@ -875,23 +876,23 @@ static bool d3d9_cg_renderchain_create_first_pass(
|
||||
return false;
|
||||
|
||||
chain->prev.tex[i] = (LPDIRECT3DTEXTURE9)
|
||||
d3d_texture_new(chain->dev, NULL,
|
||||
d3d9_texture_new(chain->dev, NULL,
|
||||
info->tex_w, info->tex_h, 1, 0,
|
||||
(fmt == RETRO_PIXEL_FORMAT_RGB565) ?
|
||||
d3d_get_rgb565_format() : d3d_get_xrgb8888_format(),
|
||||
d3d9_get_rgb565_format() : d3d9_get_xrgb8888_format(),
|
||||
D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL, false);
|
||||
|
||||
if (!chain->prev.tex[i])
|
||||
return false;
|
||||
|
||||
d3d_set_texture(chain->dev, 0, chain->prev.tex[i]);
|
||||
d3d_set_sampler_minfilter(chain->dev, 0,
|
||||
d3d_translate_filter(info->pass->filter));
|
||||
d3d_set_sampler_magfilter(chain->dev, 0,
|
||||
d3d_translate_filter(info->pass->filter));
|
||||
d3d_set_sampler_address_u(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_texture(chain->dev, 0, NULL);
|
||||
d3d9_set_texture(chain->dev, 0, chain->prev.tex[i]);
|
||||
d3d9_set_sampler_minfilter(chain->dev, 0,
|
||||
d3d9_translate_filter(info->pass->filter));
|
||||
d3d9_set_sampler_magfilter(chain->dev, 0,
|
||||
d3d9_translate_filter(info->pass->filter));
|
||||
d3d9_set_sampler_address_u(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_texture(chain->dev, 0, NULL);
|
||||
}
|
||||
|
||||
d3d9_cg_load_program(chain, &pass.fPrg,
|
||||
@ -950,27 +951,27 @@ static bool d3d9_cg_renderchain_set_pass_size(
|
||||
|
||||
if (width != pass->info.tex_w || height != pass->info.tex_h)
|
||||
{
|
||||
d3d_texture_free(pass->tex);
|
||||
d3d9_texture_free(pass->tex);
|
||||
|
||||
pass->info.tex_w = width;
|
||||
pass->info.tex_h = height;
|
||||
pass->pool = D3DPOOL_DEFAULT;
|
||||
pass->tex = (LPDIRECT3DTEXTURE9)
|
||||
d3d_texture_new(chain->dev, NULL,
|
||||
d3d9_texture_new(chain->dev, NULL,
|
||||
width, height, 1,
|
||||
D3DUSAGE_RENDERTARGET,
|
||||
chain->passes->data[chain->passes->count - 1].info.pass->fbo.fp_fbo ?
|
||||
D3DFMT_A32B32G32R32F : d3d_get_argb8888_format(),
|
||||
D3DFMT_A32B32G32R32F : d3d9_get_argb8888_format(),
|
||||
D3DPOOL_DEFAULT, 0, 0, 0,
|
||||
NULL, NULL, false);
|
||||
|
||||
if (!pass->tex)
|
||||
return false;
|
||||
|
||||
d3d_set_texture(chain->dev, 0, pass->tex);
|
||||
d3d_set_sampler_address_u(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_texture(chain->dev, 0, NULL);
|
||||
d3d9_set_texture(chain->dev, 0, pass->tex);
|
||||
d3d9_set_sampler_address_u(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_texture(chain->dev, 0, NULL);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1104,14 +1105,14 @@ static bool d3d9_cg_renderchain_add_pass(
|
||||
return false;
|
||||
|
||||
pass.vertex_buf = (LPDIRECT3DVERTEXBUFFER9)
|
||||
d3d_vertex_buffer_new(chain->dev,
|
||||
d3d9_vertex_buffer_new(chain->dev,
|
||||
4 * sizeof(struct CGVertex),
|
||||
D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, NULL);
|
||||
|
||||
if (!pass.vertex_buf)
|
||||
return false;
|
||||
|
||||
pass.tex = (LPDIRECT3DTEXTURE9)d3d_texture_new(
|
||||
pass.tex = (LPDIRECT3DTEXTURE9)d3d9_texture_new(
|
||||
chain->dev,
|
||||
NULL,
|
||||
info->tex_w,
|
||||
@ -1119,16 +1120,16 @@ static bool d3d9_cg_renderchain_add_pass(
|
||||
1,
|
||||
D3DUSAGE_RENDERTARGET,
|
||||
chain->passes->data[chain->passes->count - 1].info.pass->fbo.fp_fbo
|
||||
? D3DFMT_A32B32G32R32F : d3d_get_argb8888_format(),
|
||||
? D3DFMT_A32B32G32R32F : d3d9_get_argb8888_format(),
|
||||
D3DPOOL_DEFAULT, 0, 0, 0, NULL, NULL, false);
|
||||
|
||||
if (!pass.tex)
|
||||
return false;
|
||||
|
||||
d3d_set_texture(chain->dev, 0, pass.tex);
|
||||
d3d_set_sampler_address_u(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_texture(chain->dev, 0, NULL);
|
||||
d3d9_set_texture(chain->dev, 0, pass.tex);
|
||||
d3d9_set_sampler_address_u(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_texture(chain->dev, 0, NULL);
|
||||
|
||||
pass_vector_list_append(chain->passes, pass);
|
||||
|
||||
@ -1142,7 +1143,7 @@ static bool d3d9_cg_renderchain_add_lut(void *data,
|
||||
struct lut_info info;
|
||||
cg_renderchain_t *chain = (cg_renderchain_t*)data;
|
||||
LPDIRECT3DTEXTURE9 lut = (LPDIRECT3DTEXTURE9)
|
||||
d3d_texture_new(
|
||||
d3d9_texture_new(
|
||||
chain->dev,
|
||||
path,
|
||||
D3D_DEFAULT_NONPOW2,
|
||||
@ -1167,10 +1168,10 @@ static bool d3d9_cg_renderchain_add_lut(void *data,
|
||||
if (!lut)
|
||||
return false;
|
||||
|
||||
d3d_set_texture(chain->dev, 0, lut);
|
||||
d3d_set_sampler_address_u(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d_set_texture(chain->dev, 0, NULL);
|
||||
d3d9_set_texture(chain->dev, 0, lut);
|
||||
d3d9_set_sampler_address_u(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(chain->dev, 0, D3DTADDRESS_BORDER);
|
||||
d3d9_set_texture(chain->dev, 0, NULL);
|
||||
|
||||
lut_info_vector_list_append(chain->luts, info);
|
||||
|
||||
@ -1307,9 +1308,9 @@ static void cg_d3d9_renderchain_set_vertices(
|
||||
vert[i].y += 0.5f;
|
||||
}
|
||||
|
||||
verts = d3d_vertex_buffer_lock(pass->vertex_buf);
|
||||
verts = d3d9_vertex_buffer_lock(pass->vertex_buf);
|
||||
memcpy(verts, vert, sizeof(vert));
|
||||
d3d_vertex_buffer_unlock(pass->vertex_buf);
|
||||
d3d9_vertex_buffer_unlock(pass->vertex_buf);
|
||||
}
|
||||
|
||||
if (chain)
|
||||
@ -1337,17 +1338,17 @@ static void cg_d3d9_renderchain_blit_to_texture(
|
||||
(first->last_width != width || first->last_height != height)
|
||||
)
|
||||
{
|
||||
d3d_lock_rectangle(first->tex, 0, &d3dlr,
|
||||
d3d9_lock_rectangle(first->tex, 0, &d3dlr,
|
||||
NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK);
|
||||
d3d_lock_rectangle_clear(first->tex, 0, &d3dlr,
|
||||
d3d9_lock_rectangle_clear(first->tex, 0, &d3dlr,
|
||||
NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK);
|
||||
}
|
||||
|
||||
if (d3d_lock_rectangle(first->tex, 0, &d3dlr, NULL, 0, 0))
|
||||
if (d3d9_lock_rectangle(first->tex, 0, &d3dlr, NULL, 0, 0))
|
||||
{
|
||||
d3d_texture_blit(chain->pixel_size, first->tex,
|
||||
d3d9_texture_blit(chain->pixel_size, first->tex,
|
||||
&d3dlr, frame, width, height, pitch);
|
||||
d3d_unlock_rectangle(first->tex);
|
||||
d3d9_unlock_rectangle(first->tex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1360,15 +1361,15 @@ static void cg_d3d9_renderchain_unbind_all(cg_renderchain_t *chain)
|
||||
*/
|
||||
for (i = 0; i < chain->bound_tex->count; i++)
|
||||
{
|
||||
d3d_set_sampler_minfilter(chain->dev,
|
||||
d3d9_set_sampler_minfilter(chain->dev,
|
||||
chain->bound_tex->data[i], D3DTEXF_POINT);
|
||||
d3d_set_sampler_magfilter(chain->dev,
|
||||
d3d9_set_sampler_magfilter(chain->dev,
|
||||
chain->bound_tex->data[i], D3DTEXF_POINT);
|
||||
d3d_set_texture(chain->dev, chain->bound_tex->data[i], NULL);
|
||||
d3d9_set_texture(chain->dev, chain->bound_tex->data[i], NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < chain->bound_vert->count; i++)
|
||||
d3d_set_stream_source(chain->dev, chain->bound_vert->data[i], 0, 0, 0);
|
||||
d3d9_set_stream_source(chain->dev, chain->bound_vert->data[i], 0, 0, 0);
|
||||
|
||||
if (chain->bound_tex)
|
||||
{
|
||||
@ -1423,15 +1424,15 @@ static void cg_d3d9_renderchain_render_pass(
|
||||
cgD3D9BindProgram(pass->fPrg);
|
||||
cgD3D9BindProgram(pass->vPrg);
|
||||
|
||||
d3d_set_texture(chain->dev, 0, pass->tex);
|
||||
d3d_set_sampler_minfilter(chain->dev, 0,
|
||||
d3d_translate_filter(pass->info.pass->filter));
|
||||
d3d_set_sampler_magfilter(chain->dev, 0,
|
||||
d3d_translate_filter(pass->info.pass->filter));
|
||||
d3d9_set_texture(chain->dev, 0, pass->tex);
|
||||
d3d9_set_sampler_minfilter(chain->dev, 0,
|
||||
d3d9_translate_filter(pass->info.pass->filter));
|
||||
d3d9_set_sampler_magfilter(chain->dev, 0,
|
||||
d3d9_translate_filter(pass->info.pass->filter));
|
||||
|
||||
d3d_set_vertex_declaration(chain->dev, pass->vertex_decl);
|
||||
d3d9_set_vertex_declaration(chain->dev, pass->vertex_decl);
|
||||
for (i = 0; i < 4; i++)
|
||||
d3d_set_stream_source(chain->dev, i,
|
||||
d3d9_set_stream_source(chain->dev, i,
|
||||
pass->vertex_buf, 0,
|
||||
sizeof(struct CGVertex));
|
||||
|
||||
@ -1471,12 +1472,12 @@ static void cg_d3d9_renderchain_render_pass(
|
||||
|
||||
cg_d3d9_renderchain_set_params(chain, pass, pass_index);
|
||||
|
||||
d3d_draw_primitive(chain->dev, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
d3d9_draw_primitive(chain->dev, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
|
||||
/* So we don't render with linear filter into render targets,
|
||||
* which apparently looked odd (too blurry). */
|
||||
d3d_set_sampler_minfilter(chain->dev, 0, D3DTEXF_POINT);
|
||||
d3d_set_sampler_magfilter(chain->dev, 0, D3DTEXF_POINT);
|
||||
d3d9_set_sampler_minfilter(chain->dev, 0, D3DTEXF_POINT);
|
||||
d3d9_set_sampler_magfilter(chain->dev, 0, D3DTEXF_POINT);
|
||||
|
||||
cg_d3d9_renderchain_unbind_all(chain);
|
||||
}
|
||||
@ -1505,7 +1506,7 @@ static bool d3d9_cg_renderchain_render(
|
||||
frame_data, width, height, pitch);
|
||||
|
||||
/* Grab back buffer. */
|
||||
d3d_device_get_render_target(chain->dev, 0, (void**)&back_buffer);
|
||||
d3d9_device_get_render_target(chain->dev, 0, (void**)&back_buffer);
|
||||
|
||||
/* In-between render target passes. */
|
||||
for (i = 0; i < chain->passes->count - 1; i++)
|
||||
@ -1514,9 +1515,9 @@ static bool d3d9_cg_renderchain_render(
|
||||
struct Pass *from_pass = (struct Pass*)&chain->passes->data[i];
|
||||
struct Pass *to_pass = (struct Pass*)&chain->passes->data[i + 1];
|
||||
|
||||
d3d_texture_get_surface_level(to_pass->tex, 0, (void**)&target);
|
||||
d3d9_texture_get_surface_level(to_pass->tex, 0, (void**)&target);
|
||||
|
||||
d3d_device_set_render_target(chain->dev, 0, (void*)target);
|
||||
d3d9_device_set_render_target(chain->dev, 0, (void*)target);
|
||||
|
||||
d3d9_cg_renderchain_convert_geometry(chain, &from_pass->info,
|
||||
&out_width, &out_height,
|
||||
@ -1528,13 +1529,13 @@ static bool d3d9_cg_renderchain_render(
|
||||
viewport.MinZ = 0.0f;
|
||||
viewport.MaxZ = 1.0f;
|
||||
|
||||
d3d_set_viewports(chain->dev, &viewport);
|
||||
d3d_clear(chain->dev, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
||||
d3d9_set_viewports(chain->dev, &viewport);
|
||||
d3d9_clear(chain->dev, 0, 0, D3DCLEAR_TARGET, 0, 1, 0);
|
||||
|
||||
viewport.Width = out_width;
|
||||
viewport.Height = out_height;
|
||||
|
||||
d3d_set_viewports(chain->dev, &viewport);
|
||||
d3d9_set_viewports(chain->dev, &viewport);
|
||||
|
||||
cg_d3d9_renderchain_set_vertices(chain, from_pass,
|
||||
current_width, current_height,
|
||||
@ -1546,11 +1547,11 @@ static bool d3d9_cg_renderchain_render(
|
||||
|
||||
current_width = out_width;
|
||||
current_height = out_height;
|
||||
d3d_surface_free(target);
|
||||
d3d9_surface_free(target);
|
||||
}
|
||||
|
||||
/* Final pass */
|
||||
d3d_device_set_render_target(chain->dev, 0, (void*)back_buffer);
|
||||
d3d9_device_set_render_target(chain->dev, 0, (void*)back_buffer);
|
||||
|
||||
last_pass = (struct Pass*)&chain->passes->
|
||||
data[chain->passes->count - 1];
|
||||
@ -1559,7 +1560,7 @@ static bool d3d9_cg_renderchain_render(
|
||||
&out_width, &out_height,
|
||||
current_width, current_height, chain->final_viewport);
|
||||
|
||||
d3d_set_viewports(chain->dev, chain->final_viewport);
|
||||
d3d9_set_viewports(chain->dev, chain->final_viewport);
|
||||
|
||||
cg_d3d9_renderchain_set_vertices(chain, last_pass,
|
||||
current_width, current_height,
|
||||
@ -1573,7 +1574,7 @@ static bool d3d9_cg_renderchain_render(
|
||||
|
||||
chain->frame_count++;
|
||||
|
||||
d3d_surface_free(back_buffer);
|
||||
d3d9_surface_free(back_buffer);
|
||||
|
||||
if (chain)
|
||||
{
|
||||
@ -1639,18 +1640,18 @@ static bool d3d9_cg_renderchain_read_viewport(
|
||||
(void)buffer;
|
||||
|
||||
if (
|
||||
!d3d_device_get_render_target(d3dr, 0, (void**)&target) ||
|
||||
!d3d_device_create_offscreen_plain_surface(d3dr, width, height,
|
||||
d3d_get_xrgb8888_format(),
|
||||
!d3d9_device_get_render_target(d3dr, 0, (void**)&target) ||
|
||||
!d3d9_device_create_offscreen_plain_surface(d3dr, width, height,
|
||||
d3d9_get_xrgb8888_format(),
|
||||
D3DPOOL_SYSTEMMEM, (void**)&dest, NULL) ||
|
||||
!d3d_device_get_render_target_data(d3dr, (void*)target, (void*)dest)
|
||||
!d3d9_device_get_render_target_data(d3dr, (void*)target, (void*)dest)
|
||||
)
|
||||
{
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (d3d_surface_lock_rect(dest, (void*)&rect))
|
||||
if (d3d9_surface_lock_rect(dest, (void*)&rect))
|
||||
{
|
||||
unsigned x, y;
|
||||
unsigned pitchpix = rect.Pitch / 4;
|
||||
@ -1670,16 +1671,16 @@ static bool d3d9_cg_renderchain_read_viewport(
|
||||
}
|
||||
}
|
||||
|
||||
d3d_surface_unlock_rect((void*)dest);
|
||||
d3d9_surface_unlock_rect((void*)dest);
|
||||
}
|
||||
else
|
||||
ret = false;
|
||||
|
||||
end:
|
||||
if (target)
|
||||
d3d_surface_free(target);
|
||||
d3d9_surface_free(target);
|
||||
if (dest)
|
||||
d3d_surface_free(dest);
|
||||
d3d9_surface_free(dest);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "../drivers/d3d.h"
|
||||
#include "../../defines/d3d_defines.h"
|
||||
#include "../common/d3d_common.h"
|
||||
#include "../common/d3d9_common.h"
|
||||
|
||||
#include "../video_driver.h"
|
||||
|
||||
@ -47,8 +48,8 @@ static void hlsl_d3d9_renderchain_clear(void *data)
|
||||
{
|
||||
hlsl_d3d9_renderchain_t *chain = (hlsl_d3d9_renderchain_t*)data;
|
||||
|
||||
d3d_texture_free(chain->tex);
|
||||
d3d_vertex_buffer_free(chain->vertex_buf, chain->vertex_decl);
|
||||
d3d9_texture_free(chain->tex);
|
||||
d3d9_vertex_buffer_free(chain->vertex_buf, chain->vertex_decl);
|
||||
}
|
||||
|
||||
static bool hlsl_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||
@ -66,7 +67,7 @@ static bool hlsl_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||
|
||||
(void)pass_data;
|
||||
|
||||
return d3d_vertex_declaration_new(d3d->dev,
|
||||
return d3d9_vertex_declaration_new(d3d->dev,
|
||||
VertexElements, (void**)&chain->vertex_decl);
|
||||
}
|
||||
|
||||
@ -77,7 +78,7 @@ static bool hlsl_d3d9_renderchain_create_first_pass(void *data,
|
||||
hlsl_d3d9_renderchain_t *chain = (hlsl_d3d9_renderchain_t*)
|
||||
d3d->renderchain_data;
|
||||
|
||||
chain->vertex_buf = d3d_vertex_buffer_new(
|
||||
chain->vertex_buf = d3d9_vertex_buffer_new(
|
||||
d3d->dev, 4 * sizeof(Vertex),
|
||||
D3DUSAGE_WRITEONLY,
|
||||
#ifdef _XBOX
|
||||
@ -91,19 +92,19 @@ static bool hlsl_d3d9_renderchain_create_first_pass(void *data,
|
||||
if (!chain->vertex_buf)
|
||||
return false;
|
||||
|
||||
chain->tex = d3d_texture_new(d3d->dev, NULL,
|
||||
chain->tex = d3d9_texture_new(d3d->dev, NULL,
|
||||
chain->tex_w, chain->tex_h, 1, 0,
|
||||
info->rgb32 ?
|
||||
d3d_get_xrgb8888_format() : d3d_get_rgb565_format(),
|
||||
d3d9_get_xrgb8888_format() : d3d9_get_rgb565_format(),
|
||||
0, 0, 0, 0, NULL, NULL, false);
|
||||
|
||||
if (!chain->tex)
|
||||
return false;
|
||||
|
||||
d3d_set_sampler_address_u(d3d->dev, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
|
||||
d3d_set_sampler_address_v(d3d->dev, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
|
||||
d3d_set_render_state(d3d->dev, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
d3d_set_render_state(d3d->dev, D3DRS_ZENABLE, FALSE);
|
||||
d3d9_set_sampler_address_u(d3d->dev, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
|
||||
d3d9_set_sampler_address_v(d3d->dev, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
|
||||
d3d9_set_render_state(d3d->dev, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
d3d9_set_render_state(d3d->dev, D3DRS_ZENABLE, FALSE);
|
||||
|
||||
if (!hlsl_d3d9_renderchain_init_shader_fvf(chain, chain))
|
||||
return false;
|
||||
@ -168,9 +169,9 @@ static void hlsl_d3d9_renderchain_set_vertices(
|
||||
vert[i].y += 0.5f / ((float)chain->tex_h);
|
||||
}
|
||||
|
||||
verts = d3d_vertex_buffer_lock(chain->vertex_buf);
|
||||
verts = d3d9_vertex_buffer_lock(chain->vertex_buf);
|
||||
memcpy(verts, vert, sizeof(vert));
|
||||
d3d_vertex_buffer_unlock(chain->vertex_buf);
|
||||
d3d9_vertex_buffer_unlock(chain->vertex_buf);
|
||||
}
|
||||
|
||||
shader_info.data = d3d;
|
||||
@ -205,20 +206,20 @@ static void hlsl_d3d9_renderchain_blit_to_texture(
|
||||
|
||||
if (chain->last_width != width || chain->last_height != height)
|
||||
{
|
||||
d3d_lock_rectangle(chain->tex,
|
||||
d3d9_lock_rectangle(chain->tex,
|
||||
0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK);
|
||||
d3d_lock_rectangle_clear(chain->tex,
|
||||
d3d9_lock_rectangle_clear(chain->tex,
|
||||
0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK);
|
||||
}
|
||||
|
||||
/* Set the texture to NULL so D3D doesn't complain about it being in use... */
|
||||
d3d_set_texture(chain->dev, 0, NULL);
|
||||
d3d9_set_texture(chain->dev, 0, NULL);
|
||||
|
||||
if (d3d_lock_rectangle(chain->tex, 0, &d3dlr, NULL, 0, 0))
|
||||
if (d3d9_lock_rectangle(chain->tex, 0, &d3dlr, NULL, 0, 0))
|
||||
{
|
||||
d3d_texture_blit(chain->pixel_size, chain->tex,
|
||||
d3d9_texture_blit(chain->pixel_size, chain->tex,
|
||||
&d3dlr, frame, width, height, pitch);
|
||||
d3d_unlock_rectangle(chain->tex);
|
||||
d3d9_unlock_rectangle(chain->tex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,17 +356,17 @@ static bool hlsl_d3d9_renderchain_render(void *data, const void *frame,
|
||||
hlsl_d3d9_renderchain_set_vertices(d3d,
|
||||
1, frame_width, frame_height, chain->frame_count);
|
||||
|
||||
d3d_set_texture(chain->dev, 0, chain->tex);
|
||||
d3d_set_viewports(chain->dev, &d3d->final_viewport);
|
||||
d3d_set_sampler_minfilter(chain->dev, 0,
|
||||
d3d9_set_texture(chain->dev, 0, chain->tex);
|
||||
d3d9_set_viewports(chain->dev, &d3d->final_viewport);
|
||||
d3d9_set_sampler_minfilter(chain->dev, 0,
|
||||
video_smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT);
|
||||
d3d_set_sampler_magfilter(chain->dev, 0,
|
||||
d3d9_set_sampler_magfilter(chain->dev, 0,
|
||||
video_smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT);
|
||||
|
||||
d3d_set_vertex_declaration(chain->dev, chain->vertex_decl);
|
||||
d3d9_set_vertex_declaration(chain->dev, chain->vertex_decl);
|
||||
for (i = 0; i < 4; i++)
|
||||
d3d_set_stream_source(chain->dev, i, chain->vertex_buf, 0, sizeof(Vertex));
|
||||
d3d_draw_primitive(chain->dev, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
d3d9_set_stream_source(chain->dev, i, chain->vertex_buf, 0, sizeof(Vertex));
|
||||
d3d9_draw_primitive(chain->dev, D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -82,35 +82,67 @@ int font_renderer_create_default(const void **data, void **handle,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_D3D
|
||||
static const font_renderer_t *d3d_font_backends[] = {
|
||||
#if defined(_XBOX360)
|
||||
&d3d_xbox360_font,
|
||||
#elif defined(_WIN32) && defined(HAVE_D3DX)
|
||||
&d3d_win32_font,
|
||||
#elif defined(_XBOX1)
|
||||
#ifdef HAVE_D3D8
|
||||
static const font_renderer_t *d3d8_font_backends[] = {
|
||||
#if defined(_XBOX1)
|
||||
&d3d_xdk1_font,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
static bool d3d_font_init_first(
|
||||
static bool d3d8_font_init_first(
|
||||
const void **font_driver, void **font_handle,
|
||||
void *video_data, const char *font_path,
|
||||
float font_size, bool is_threaded)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(d3d_font_backends); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(d3d8_font_backends); i++)
|
||||
{
|
||||
void *data = d3d_font_backends[i] ? d3d_font_backends[i]->init(
|
||||
void *data = d3d8_font_backends[i] ? d3d8_font_backends[i]->init(
|
||||
video_data, font_path, font_size,
|
||||
is_threaded) : NULL;
|
||||
|
||||
if (!data)
|
||||
continue;
|
||||
|
||||
*font_driver = d3d_font_backends[i];
|
||||
*font_driver = d3d8_font_backends[i];
|
||||
*font_handle = data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_D3D9
|
||||
static const font_renderer_t *d3d9_font_backends[] = {
|
||||
#if defined(_XBOX)
|
||||
&d3d_xbox360_font,
|
||||
#elif defined(_WIN32) && defined(HAVE_D3DX)
|
||||
&d3d_win32_font,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
static bool d3d9_font_init_first(
|
||||
const void **font_driver, void **font_handle,
|
||||
void *video_data, const char *font_path,
|
||||
float font_size, bool is_threaded)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(d3d9_font_backends); i++)
|
||||
{
|
||||
void *data = d3d9_font_backends[i] ? d3d9_font_backends[i]->init(
|
||||
video_data, font_path, font_size,
|
||||
is_threaded) : NULL;
|
||||
|
||||
if (!data)
|
||||
continue;
|
||||
|
||||
*font_driver = d3d9_font_backends[i];
|
||||
*font_handle = data;
|
||||
|
||||
return true;
|
||||
@ -441,11 +473,6 @@ static bool font_init_first(
|
||||
|
||||
switch (api)
|
||||
{
|
||||
#ifdef HAVE_D3D
|
||||
case FONT_DRIVER_RENDER_DIRECT3D_API:
|
||||
return d3d_font_init_first(font_driver, font_handle,
|
||||
video_data, font_path, font_size, is_threaded);
|
||||
#endif
|
||||
#ifdef HAVE_OPENGL
|
||||
case FONT_DRIVER_RENDER_OPENGL_API:
|
||||
return gl_font_init_first(font_driver, font_handle,
|
||||
@ -456,6 +483,16 @@ static bool font_init_first(
|
||||
return vulkan_font_init_first(font_driver, font_handle,
|
||||
video_data, font_path, font_size, is_threaded);
|
||||
#endif
|
||||
#ifdef HAVE_D3D8
|
||||
case FONT_DRIVER_RENDER_D3D8_API:
|
||||
return d3d8_font_init_first(font_driver, font_handle,
|
||||
video_data, font_path, font_size, is_threaded);
|
||||
#endif
|
||||
#ifdef HAVE_D3D9
|
||||
case FONT_DRIVER_RENDER_D3D9_API:
|
||||
return d3d9_font_init_first(font_driver, font_handle,
|
||||
video_data, font_path, font_size, is_threaded);
|
||||
#endif
|
||||
#ifdef HAVE_D3D11
|
||||
case FONT_DRIVER_RENDER_D3D11_API:
|
||||
return d3d11_font_init_first(font_driver, font_handle,
|
||||
|
@ -30,7 +30,8 @@ enum font_driver_render_api
|
||||
{
|
||||
FONT_DRIVER_RENDER_DONT_CARE,
|
||||
FONT_DRIVER_RENDER_OPENGL_API,
|
||||
FONT_DRIVER_RENDER_DIRECT3D_API,
|
||||
FONT_DRIVER_RENDER_D3D8_API,
|
||||
FONT_DRIVER_RENDER_D3D9_API,
|
||||
FONT_DRIVER_RENDER_D3D11_API,
|
||||
FONT_DRIVER_RENDER_D3D12_API,
|
||||
FONT_DRIVER_RENDER_VITA2D,
|
||||
|
@ -1158,8 +1158,12 @@ MENU
|
||||
|
||||
#include "../menu/drivers_display/menu_display_null.c"
|
||||
|
||||
#if defined(HAVE_D3D)
|
||||
#include "../menu/drivers_display/menu_display_d3d.c"
|
||||
#if defined(HAVE_D3D8)
|
||||
#include "../menu/drivers_display/menu_display_d3d8.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_D3D9)
|
||||
#include "../menu/drivers_display/menu_display_d3d9.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_D3D11)
|
||||
|
@ -271,6 +271,8 @@ cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
void d3d9_make_d3dpp(void *data, const video_info_t *info, void *_d3dpp);
|
||||
|
||||
static void* xui_init(void **userdata, bool video_is_threaded)
|
||||
{
|
||||
HRESULT hr;
|
||||
@ -296,7 +298,7 @@ static void* xui_init(void **userdata, bool video_is_threaded)
|
||||
video_info.fullscreen = true;
|
||||
video_info.rgb32 = false;
|
||||
|
||||
d3d_make_d3dpp(d3d, &video_info, &d3dpp);
|
||||
d3d9_make_d3dpp(d3d, &video_info, &d3dpp);
|
||||
|
||||
hr = app.InitShared((D3DDevice*)d3d->dev, &d3dpp,
|
||||
(PFN_XUITEXTURELOADER)XuiTextureLoader);
|
||||
|
288
menu/drivers_display/menu_display_d3d8.c
Normal file
288
menu/drivers_display/menu_display_d3d8.c
Normal file
@ -0,0 +1,288 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#include <gfx/math/matrix_4x4.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
#include "../menu_driver.h"
|
||||
|
||||
#include "../../gfx/video_driver.h"
|
||||
#include "../../gfx/drivers/d3d.h"
|
||||
#include "../../gfx/common/d3d_common.h"
|
||||
#include "../../gfx/common/d3d8_common.h"
|
||||
|
||||
static const float d3d8_vertexes[] = {
|
||||
0, 0,
|
||||
1, 0,
|
||||
0, 1,
|
||||
1, 1
|
||||
};
|
||||
|
||||
static const float d3d8_tex_coords[] = {
|
||||
0, 1,
|
||||
1, 1,
|
||||
0, 0,
|
||||
1, 0
|
||||
};
|
||||
|
||||
static const float *menu_display_d3d8_get_default_vertices(void)
|
||||
{
|
||||
return &d3d8_vertexes[0];
|
||||
}
|
||||
|
||||
static const float *menu_display_d3d8_get_default_tex_coords(void)
|
||||
{
|
||||
return &d3d8_tex_coords[0];
|
||||
}
|
||||
|
||||
static void *menu_display_d3d8_get_default_mvp(video_frame_info_t *video_info)
|
||||
{
|
||||
static math_matrix_4x4 id;
|
||||
matrix_4x4_identity(id);
|
||||
|
||||
return &id;
|
||||
}
|
||||
|
||||
static INT32 menu_display_prim_to_d3d8_enum(
|
||||
enum menu_display_prim_type prim_type)
|
||||
{
|
||||
switch (prim_type)
|
||||
{
|
||||
case MENU_DISPLAY_PRIM_TRIANGLES:
|
||||
case MENU_DISPLAY_PRIM_TRIANGLESTRIP:
|
||||
return D3DPT_COMM_TRIANGLESTRIP;
|
||||
case MENU_DISPLAY_PRIM_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* TOD/FIXME - hack */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void menu_display_d3d8_blend_begin(video_frame_info_t *video_info)
|
||||
{
|
||||
d3d_video_t *d3d = video_info ?
|
||||
(d3d_video_t*)video_info->userdata : NULL;
|
||||
|
||||
if (!d3d)
|
||||
return;
|
||||
|
||||
d3d8_enable_blend_func(d3d->dev);
|
||||
}
|
||||
|
||||
static void menu_display_d3d8_blend_end(video_frame_info_t *video_info)
|
||||
{
|
||||
d3d_video_t *d3d = video_info ?
|
||||
(d3d_video_t*)video_info->userdata : NULL;
|
||||
|
||||
if (!d3d)
|
||||
return;
|
||||
|
||||
d3d8_disable_blend_func(d3d->dev);
|
||||
}
|
||||
|
||||
static void menu_display_d3d8_viewport(void *data, video_frame_info_t *video_info)
|
||||
{
|
||||
}
|
||||
|
||||
static void menu_display_d3d8_bind_texture(void *data, d3d_video_t *d3d)
|
||||
{
|
||||
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
|
||||
|
||||
if (!d3d || !draw || !draw->texture)
|
||||
return;
|
||||
|
||||
d3d8_set_texture(d3d->dev, 0, (void*)draw->texture);
|
||||
d3d8_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_COMM_CLAMP);
|
||||
d3d8_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_COMM_CLAMP);
|
||||
d3d8_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_COMM_LINEAR);
|
||||
d3d8_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_COMM_LINEAR);
|
||||
d3d8_set_sampler_mipfilter(d3d->dev, 0, D3DTEXF_COMM_LINEAR);
|
||||
}
|
||||
|
||||
static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
|
||||
{
|
||||
unsigned i;
|
||||
video_shader_ctx_mvp_t mvp;
|
||||
math_matrix_4x4 mop, m1, m2;
|
||||
unsigned width, height;
|
||||
d3d_video_t *d3d = video_info ? (d3d_video_t*)video_info->userdata : NULL;
|
||||
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
|
||||
Vertex * pv = NULL;
|
||||
const float *vertex = NULL;
|
||||
const float *tex_coord = NULL;
|
||||
const float *color = NULL;
|
||||
|
||||
if (!d3d || !draw || draw->pipeline.id)
|
||||
return;
|
||||
if((d3d->menu_display.offset + draw->coords->vertices )
|
||||
> (unsigned)d3d->menu_display.size)
|
||||
return;
|
||||
|
||||
pv = (Vertex*)
|
||||
d3d8_vertex_buffer_lock(d3d->menu_display.buffer);
|
||||
|
||||
if (!pv)
|
||||
return;
|
||||
|
||||
pv += d3d->menu_display.offset;
|
||||
vertex = draw->coords->vertex;
|
||||
tex_coord = draw->coords->tex_coord;
|
||||
color = draw->coords->color;
|
||||
|
||||
if (!vertex)
|
||||
vertex = menu_display_d3d8_get_default_vertices();
|
||||
if (!tex_coord)
|
||||
tex_coord = menu_display_d3d8_get_default_tex_coords();
|
||||
|
||||
for (i = 0; i < draw->coords->vertices; i++)
|
||||
{
|
||||
int colors[4];
|
||||
|
||||
colors[0] = *color++ * 0xFF;
|
||||
colors[1] = *color++ * 0xFF;
|
||||
colors[2] = *color++ * 0xFF;
|
||||
colors[3] = *color++ * 0xFF;
|
||||
|
||||
pv[i].x = *vertex++;
|
||||
pv[i].y = *vertex++;
|
||||
pv[i].z = 0.5f;
|
||||
pv[i].u = *tex_coord++;
|
||||
pv[i].v = *tex_coord++;
|
||||
|
||||
#if 1
|
||||
if ((void*)draw->texture)
|
||||
{
|
||||
D3DSURFACE_DESC desc;
|
||||
if (d3d8_texture_get_level_desc((void*)draw->texture, 0, &desc))
|
||||
{
|
||||
pv[i].u *= desc.Width;
|
||||
pv[i].v *= desc.Height;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pv[i].color =
|
||||
D3DCOLOR_ARGB(
|
||||
colors[3], /* A */
|
||||
colors[0], /* R */
|
||||
colors[1], /* G */
|
||||
colors[2] /* B */
|
||||
);
|
||||
}
|
||||
d3d8_vertex_buffer_unlock(d3d->menu_display.buffer);
|
||||
|
||||
if(!draw->matrix_data)
|
||||
draw->matrix_data = menu_display_d3d8_get_default_mvp(video_info);
|
||||
|
||||
/* ugh */
|
||||
video_driver_get_size(&width, &height);
|
||||
matrix_4x4_scale(m1, 2.0, 2.0, 0);
|
||||
matrix_4x4_translate(mop, -1.0, -1.0, 0);
|
||||
matrix_4x4_multiply(m2, mop, m1);
|
||||
matrix_4x4_multiply(m1,
|
||||
*((math_matrix_4x4*)draw->matrix_data), m2);
|
||||
matrix_4x4_scale(mop,
|
||||
(draw->width / 2.0) / width,
|
||||
(draw->height / 2.0) / height, 0);
|
||||
matrix_4x4_multiply(m2, mop, m1);
|
||||
matrix_4x4_translate(mop,
|
||||
(draw->x + (draw->width / 2.0)) / width,
|
||||
(draw->y + (draw->height / 2.0)) / height,
|
||||
0);
|
||||
matrix_4x4_multiply(m1, mop, m2);
|
||||
matrix_4x4_multiply(m2, d3d->mvp_transposed, m1);
|
||||
d3d_matrix_transpose(&m1, &m2);
|
||||
|
||||
mvp.data = d3d;
|
||||
mvp.matrix = &m1;
|
||||
video_driver_set_mvp(&mvp);
|
||||
menu_display_d3d8_bind_texture(draw, (d3d_video_t*)video_info->userdata);
|
||||
d3d8_draw_primitive(d3d->dev,
|
||||
menu_display_prim_to_d3d8_enum(draw->prim_type),
|
||||
d3d->menu_display.offset,
|
||||
draw->coords->vertices -
|
||||
((draw->prim_type == MENU_DISPLAY_PRIM_TRIANGLESTRIP)
|
||||
? 2 : 0));
|
||||
|
||||
d3d->menu_display.offset += draw->coords->vertices;
|
||||
}
|
||||
|
||||
static void menu_display_d3d8_draw_pipeline(void *data,
|
||||
video_frame_info_t *video_info)
|
||||
{
|
||||
}
|
||||
|
||||
static void menu_display_d3d8_restore_clear_color(void)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
static void menu_display_d3d8_clear_color(
|
||||
menu_display_ctx_clearcolor_t *clearcolor, video_frame_info_t *video_info)
|
||||
{
|
||||
DWORD clear_color = 0;
|
||||
d3d_video_t *d3d = video_info ?
|
||||
(d3d_video_t*)video_info->userdata : NULL;
|
||||
|
||||
if (!d3d || !clearcolor)
|
||||
return;
|
||||
|
||||
clear_color = D3DCOLOR_ARGB(
|
||||
BYTE_CLAMP(clearcolor->a * 255.0f), /* A */
|
||||
BYTE_CLAMP(clearcolor->r * 255.0f), /* R */
|
||||
BYTE_CLAMP(clearcolor->g * 255.0f), /* G */
|
||||
BYTE_CLAMP(clearcolor->b * 255.0f) /* B */
|
||||
);
|
||||
|
||||
d3d8_clear(d3d->dev, 0, NULL, D3D_COMM_CLEAR_TARGET, clear_color, 0, 0);
|
||||
}
|
||||
|
||||
static bool menu_display_d3d8_font_init_first(
|
||||
void **font_handle, void *video_data,
|
||||
const char *font_path, float font_size,
|
||||
bool is_threaded)
|
||||
{
|
||||
font_data_t **handle = (font_data_t**)font_handle;
|
||||
if (!(*handle = font_driver_init_first(video_data,
|
||||
font_path, font_size, true,
|
||||
is_threaded,
|
||||
FONT_DRIVER_RENDER_D3D8_API)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
menu_display_ctx_driver_t menu_display_ctx_d3d8 = {
|
||||
menu_display_d3d8_draw,
|
||||
menu_display_d3d8_draw_pipeline,
|
||||
menu_display_d3d8_viewport,
|
||||
menu_display_d3d8_blend_begin,
|
||||
menu_display_d3d8_blend_end,
|
||||
menu_display_d3d8_restore_clear_color,
|
||||
menu_display_d3d8_clear_color,
|
||||
menu_display_d3d8_get_default_mvp,
|
||||
menu_display_d3d8_get_default_vertices,
|
||||
menu_display_d3d8_get_default_tex_coords,
|
||||
menu_display_d3d8_font_init_first,
|
||||
MENU_VIDEO_DRIVER_DIRECT3D8,
|
||||
"menu_display_d3d8",
|
||||
false
|
||||
};
|
@ -26,34 +26,33 @@
|
||||
#include "../../gfx/video_driver.h"
|
||||
#include "../../gfx/drivers/d3d.h"
|
||||
#include "../../gfx/common/d3d_common.h"
|
||||
#include "../../gfx/common/d3d9_common.h"
|
||||
|
||||
#define BYTE_CLAMP(i) (int) ((((i) > 255) ? 255 : (((i) < 0) ? 0 : (i))))
|
||||
|
||||
static const float d3d_vertexes[] = {
|
||||
static const float d3d9_vertexes[] = {
|
||||
0, 0,
|
||||
1, 0,
|
||||
0, 1,
|
||||
1, 1
|
||||
};
|
||||
|
||||
static const float d3d_tex_coords[] = {
|
||||
static const float d3d9_tex_coords[] = {
|
||||
0, 1,
|
||||
1, 1,
|
||||
0, 0,
|
||||
1, 0
|
||||
};
|
||||
|
||||
static const float *menu_display_d3d_get_default_vertices(void)
|
||||
static const float *menu_display_d3d9_get_default_vertices(void)
|
||||
{
|
||||
return &d3d_vertexes[0];
|
||||
return &d3d9_vertexes[0];
|
||||
}
|
||||
|
||||
static const float *menu_display_d3d_get_default_tex_coords(void)
|
||||
static const float *menu_display_d3d9_get_default_tex_coords(void)
|
||||
{
|
||||
return &d3d_tex_coords[0];
|
||||
return &d3d9_tex_coords[0];
|
||||
}
|
||||
|
||||
static void *menu_display_d3d_get_default_mvp(video_frame_info_t *video_info)
|
||||
static void *menu_display_d3d9_get_default_mvp(video_frame_info_t *video_info)
|
||||
{
|
||||
static math_matrix_4x4 id;
|
||||
matrix_4x4_identity(id);
|
||||
@ -61,7 +60,7 @@ static void *menu_display_d3d_get_default_mvp(video_frame_info_t *video_info)
|
||||
return &id;
|
||||
}
|
||||
|
||||
static INT32 menu_display_prim_to_d3d_enum(
|
||||
static INT32 menu_display_prim_to_d3d9_enum(
|
||||
enum menu_display_prim_type prim_type)
|
||||
{
|
||||
switch (prim_type)
|
||||
@ -78,7 +77,7 @@ static INT32 menu_display_prim_to_d3d_enum(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void menu_display_d3d_blend_begin(video_frame_info_t *video_info)
|
||||
static void menu_display_d3d9_blend_begin(video_frame_info_t *video_info)
|
||||
{
|
||||
d3d_video_t *d3d = video_info ?
|
||||
(d3d_video_t*)video_info->userdata : NULL;
|
||||
@ -86,10 +85,10 @@ static void menu_display_d3d_blend_begin(video_frame_info_t *video_info)
|
||||
if (!d3d)
|
||||
return;
|
||||
|
||||
d3d_enable_blend_func(d3d->dev);
|
||||
d3d9_enable_blend_func(d3d->dev);
|
||||
}
|
||||
|
||||
static void menu_display_d3d_blend_end(video_frame_info_t *video_info)
|
||||
static void menu_display_d3d9_blend_end(video_frame_info_t *video_info)
|
||||
{
|
||||
d3d_video_t *d3d = video_info ?
|
||||
(d3d_video_t*)video_info->userdata : NULL;
|
||||
@ -97,29 +96,29 @@ static void menu_display_d3d_blend_end(video_frame_info_t *video_info)
|
||||
if (!d3d)
|
||||
return;
|
||||
|
||||
d3d_disable_blend_func(d3d->dev);
|
||||
d3d9_disable_blend_func(d3d->dev);
|
||||
}
|
||||
|
||||
static void menu_display_d3d_viewport(void *data, video_frame_info_t *video_info)
|
||||
static void menu_display_d3d9_viewport(void *data, video_frame_info_t *video_info)
|
||||
{
|
||||
}
|
||||
|
||||
static void menu_display_d3d_bind_texture(void *data, d3d_video_t *d3d)
|
||||
static void menu_display_d3d9_bind_texture(void *data, d3d_video_t *d3d)
|
||||
{
|
||||
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
|
||||
|
||||
if (!d3d || !draw || !draw->texture)
|
||||
return;
|
||||
|
||||
d3d_set_texture(d3d->dev, 0, (void*)draw->texture);
|
||||
d3d_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_COMM_CLAMP);
|
||||
d3d_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_COMM_CLAMP);
|
||||
d3d_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_COMM_LINEAR);
|
||||
d3d_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_COMM_LINEAR);
|
||||
d3d_set_sampler_mipfilter(d3d->dev, 0, D3DTEXF_COMM_LINEAR);
|
||||
d3d9_set_texture(d3d->dev, 0, (void*)draw->texture);
|
||||
d3d9_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_COMM_CLAMP);
|
||||
d3d9_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_COMM_CLAMP);
|
||||
d3d9_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_COMM_LINEAR);
|
||||
d3d9_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_COMM_LINEAR);
|
||||
d3d9_set_sampler_mipfilter(d3d->dev, 0, D3DTEXF_COMM_LINEAR);
|
||||
}
|
||||
|
||||
static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
|
||||
static void menu_display_d3d9_draw(void *data, video_frame_info_t *video_info)
|
||||
{
|
||||
unsigned i;
|
||||
video_shader_ctx_mvp_t mvp;
|
||||
@ -139,7 +138,7 @@ static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
|
||||
return;
|
||||
|
||||
pv = (Vertex*)
|
||||
d3d_vertex_buffer_lock(d3d->menu_display.buffer);
|
||||
d3d9_vertex_buffer_lock(d3d->menu_display.buffer);
|
||||
|
||||
if (!pv)
|
||||
return;
|
||||
@ -150,9 +149,9 @@ static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
|
||||
color = draw->coords->color;
|
||||
|
||||
if (!vertex)
|
||||
vertex = menu_display_d3d_get_default_vertices();
|
||||
vertex = menu_display_d3d9_get_default_vertices();
|
||||
if (!tex_coord)
|
||||
tex_coord = menu_display_d3d_get_default_tex_coords();
|
||||
tex_coord = menu_display_d3d9_get_default_tex_coords();
|
||||
|
||||
for (i = 0; i < draw->coords->vertices; i++)
|
||||
{
|
||||
@ -168,17 +167,6 @@ static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
|
||||
pv[i].z = 0.5f;
|
||||
pv[i].u = *tex_coord++;
|
||||
pv[i].v = *tex_coord++;
|
||||
#ifdef HAVE_D3D8
|
||||
if ((void*)draw->texture)
|
||||
{
|
||||
D3DSURFACE_DESC desc;
|
||||
if (d3d_texture_get_level_desc((void*)draw->texture, 0, &desc))
|
||||
{
|
||||
pv[i].u *= desc.Width;
|
||||
pv[i].v *= desc.Height;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pv[i].color =
|
||||
D3DCOLOR_ARGB(
|
||||
@ -188,10 +176,10 @@ static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
|
||||
colors[2] /* B */
|
||||
);
|
||||
}
|
||||
d3d_vertex_buffer_unlock(d3d->menu_display.buffer);
|
||||
d3d9_vertex_buffer_unlock(d3d->menu_display.buffer);
|
||||
|
||||
if(!draw->matrix_data)
|
||||
draw->matrix_data = menu_display_d3d_get_default_mvp(video_info);
|
||||
draw->matrix_data = menu_display_d3d9_get_default_mvp(video_info);
|
||||
|
||||
/* ugh */
|
||||
video_driver_get_size(&width, &height);
|
||||
@ -215,9 +203,9 @@ static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
|
||||
mvp.data = d3d;
|
||||
mvp.matrix = &m1;
|
||||
video_driver_set_mvp(&mvp);
|
||||
menu_display_d3d_bind_texture(draw, (d3d_video_t*)video_info->userdata);
|
||||
d3d_draw_primitive(d3d->dev,
|
||||
menu_display_prim_to_d3d_enum(draw->prim_type),
|
||||
menu_display_d3d9_bind_texture(draw, (d3d_video_t*)video_info->userdata);
|
||||
d3d9_draw_primitive(d3d->dev,
|
||||
menu_display_prim_to_d3d9_enum(draw->prim_type),
|
||||
d3d->menu_display.offset,
|
||||
draw->coords->vertices -
|
||||
((draw->prim_type == MENU_DISPLAY_PRIM_TRIANGLESTRIP)
|
||||
@ -226,7 +214,7 @@ static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
|
||||
d3d->menu_display.offset += draw->coords->vertices;
|
||||
}
|
||||
|
||||
static void menu_display_d3d_draw_pipeline(void *data,
|
||||
static void menu_display_d3d9_draw_pipeline(void *data,
|
||||
video_frame_info_t *video_info)
|
||||
{
|
||||
#if defined(HAVE_HLSL) || defined(HAVE_CG)
|
||||
@ -272,12 +260,12 @@ static void menu_display_d3d_draw_pipeline(void *data,
|
||||
#endif
|
||||
}
|
||||
|
||||
static void menu_display_d3d_restore_clear_color(void)
|
||||
static void menu_display_d3d9_restore_clear_color(void)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
static void menu_display_d3d_clear_color(
|
||||
static void menu_display_d3d9_clear_color(
|
||||
menu_display_ctx_clearcolor_t *clearcolor, video_frame_info_t *video_info)
|
||||
{
|
||||
DWORD clear_color = 0;
|
||||
@ -294,10 +282,10 @@ static void menu_display_d3d_clear_color(
|
||||
BYTE_CLAMP(clearcolor->b * 255.0f) /* B */
|
||||
);
|
||||
|
||||
d3d_clear(d3d->dev, 0, NULL, D3D_COMM_CLEAR_TARGET, clear_color, 0, 0);
|
||||
d3d9_clear(d3d->dev, 0, NULL, D3D_COMM_CLEAR_TARGET, clear_color, 0, 0);
|
||||
}
|
||||
|
||||
static bool menu_display_d3d_font_init_first(
|
||||
static bool menu_display_d3d9_font_init_first(
|
||||
void **font_handle, void *video_data,
|
||||
const char *font_path, float font_size,
|
||||
bool is_threaded)
|
||||
@ -306,24 +294,24 @@ static bool menu_display_d3d_font_init_first(
|
||||
if (!(*handle = font_driver_init_first(video_data,
|
||||
font_path, font_size, true,
|
||||
is_threaded,
|
||||
FONT_DRIVER_RENDER_DIRECT3D_API)))
|
||||
FONT_DRIVER_RENDER_D3D9_API)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
menu_display_ctx_driver_t menu_display_ctx_d3d = {
|
||||
menu_display_d3d_draw,
|
||||
menu_display_d3d_draw_pipeline,
|
||||
menu_display_d3d_viewport,
|
||||
menu_display_d3d_blend_begin,
|
||||
menu_display_d3d_blend_end,
|
||||
menu_display_d3d_restore_clear_color,
|
||||
menu_display_d3d_clear_color,
|
||||
menu_display_d3d_get_default_mvp,
|
||||
menu_display_d3d_get_default_vertices,
|
||||
menu_display_d3d_get_default_tex_coords,
|
||||
menu_display_d3d_font_init_first,
|
||||
MENU_VIDEO_DRIVER_DIRECT3D,
|
||||
"menu_display_d3d",
|
||||
menu_display_ctx_driver_t menu_display_ctx_d3d9 = {
|
||||
menu_display_d3d9_draw,
|
||||
menu_display_d3d9_draw_pipeline,
|
||||
menu_display_d3d9_viewport,
|
||||
menu_display_d3d9_blend_begin,
|
||||
menu_display_d3d9_blend_end,
|
||||
menu_display_d3d9_restore_clear_color,
|
||||
menu_display_d3d9_clear_color,
|
||||
menu_display_d3d9_get_default_mvp,
|
||||
menu_display_d3d9_get_default_vertices,
|
||||
menu_display_d3d9_get_default_tex_coords,
|
||||
menu_display_d3d9_font_init_first,
|
||||
MENU_VIDEO_DRIVER_DIRECT3D9,
|
||||
"menu_display_d3d9",
|
||||
false
|
||||
};
|
@ -87,8 +87,11 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = {
|
||||
|
||||
/* Menu display drivers */
|
||||
static menu_display_ctx_driver_t *menu_display_ctx_drivers[] = {
|
||||
#ifdef HAVE_D3D
|
||||
&menu_display_ctx_d3d,
|
||||
#ifdef HAVE_D3D8
|
||||
&menu_display_ctx_d3d8,
|
||||
#endif
|
||||
#ifdef HAVE_D3D9
|
||||
&menu_display_ctx_d3d9,
|
||||
#endif
|
||||
#ifdef HAVE_D3D11
|
||||
&menu_display_ctx_d3d11,
|
||||
@ -222,10 +225,12 @@ static bool menu_display_check_compatibility(
|
||||
if (string_is_equal(video_driver, "vulkan"))
|
||||
return true;
|
||||
break;
|
||||
case MENU_VIDEO_DRIVER_DIRECT3D:
|
||||
if ( string_is_equal(video_driver, "d3d9") ||
|
||||
string_is_equal(video_driver, "d3d8")
|
||||
)
|
||||
case MENU_VIDEO_DRIVER_DIRECT3D8:
|
||||
if (string_is_equal(video_driver, "d3d8"))
|
||||
return true;
|
||||
break;
|
||||
case MENU_VIDEO_DRIVER_DIRECT3D9:
|
||||
if (string_is_equal(video_driver, "d3d9"))
|
||||
return true;
|
||||
break;
|
||||
case MENU_VIDEO_DRIVER_DIRECT3D11:
|
||||
|
@ -284,7 +284,8 @@ enum menu_display_driver_type
|
||||
MENU_VIDEO_DRIVER_GENERIC = 0,
|
||||
MENU_VIDEO_DRIVER_OPENGL,
|
||||
MENU_VIDEO_DRIVER_VULKAN,
|
||||
MENU_VIDEO_DRIVER_DIRECT3D,
|
||||
MENU_VIDEO_DRIVER_DIRECT3D8,
|
||||
MENU_VIDEO_DRIVER_DIRECT3D9,
|
||||
MENU_VIDEO_DRIVER_DIRECT3D11,
|
||||
MENU_VIDEO_DRIVER_DIRECT3D12,
|
||||
MENU_VIDEO_DRIVER_VITA2D,
|
||||
@ -754,7 +755,8 @@ extern uintptr_t menu_display_white_texture;
|
||||
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_gl;
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_vulkan;
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_d3d;
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_d3d8;
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_d3d9;
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_d3d11;
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_d3d12;
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_vita2d;
|
||||
|
Loading…
Reference in New Issue
Block a user