blob: ac7195db8d7f4e33bc8004b06407a0dd14cf5038 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
//============================================================
//
// drawd3d.h - Win32 Direct3D header
//
//============================================================
#ifndef __WIN_DRAWD3D__
#define __WIN_DRAWD3D__
#ifdef OSD_WINDOWS
#include "d3d/d3dintf.h"
#include "d3d/d3dcomm.h"
//============================================================
// CONSTANTS
//============================================================
#define VERTEX_BASE_FORMAT (D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEX2)
#define VERTEX_BUFFER_SIZE (40960*4+4)
//============================================================
// TYPE DEFINITIONS
//============================================================
class vertex;
class texture_info;
class texture_manager;
class device;
class vertex_buffer;
class shaders;
class hlsl_options;
class poly_info;
/* renderer is the information about Direct3D for the current screen */
class renderer_d3d9 : public osd_renderer
{
public:
renderer_d3d9(osd_window *window);
virtual ~renderer_d3d9();
virtual int create() override;
virtual int init(running_machine &machine) override;
virtual render_primitive_list *get_primitives() override;
virtual int draw(const int update) override;
virtual void save() override;
virtual void record() override;
virtual void toggle_fsfx() override;
int initialize();
int device_create(HWND device_HWND);
int device_create_resources();
void device_delete();
void device_delete_resources();
int device_verify_caps();
int device_test_cooperative();
int config_adapter_mode();
void pick_best_mode();
int get_adapter_for_monitor();
int update_window_size();
int pre_window_draw_check();
void begin_frame();
void end_frame();
void draw_line(const render_primitive *prim);
void draw_quad(const render_primitive *prim);
void batch_vector(const render_primitive *prim, float line_time);
void batch_vectors();
vertex * mesh_alloc(int numverts);
void update_textures();
void process_primitives();
void primitive_flush_pending();
void set_texture(texture_info *texture);
void set_filter(int filter);
void set_wrap(unsigned int wrap);
void set_modmode(int modmode);
void set_blendmode(int blendmode);
void reset_render_states();
// Setters / getters
int get_adapter() { return m_adapter; }
int get_width() { return m_width; }
vec2f get_dims() { return vec2f(m_width, m_height); }
int get_height() { return m_height; }
int get_refresh() { return m_refresh; }
device * get_device() { return m_device; }
present_parameters * get_presentation() { return &m_presentation; }
vertex_buffer * get_vertex_buffer() { return m_vertexbuf; }
vertex * get_locked_buffer() { return m_lockedbuf; }
VOID ** get_locked_buffer_ptr() { return (VOID **)&m_lockedbuf; }
void set_locked_buffer(vertex *lockedbuf) { m_lockedbuf = lockedbuf; }
void set_restarting(bool restarting) { m_restarting = restarting; }
bool is_mod2x_supported() { return (bool)m_mod2x_supported; }
bool is_mod4x_supported() { return (bool)m_mod4x_supported; }
D3DFORMAT get_screen_format() { return m_screen_format; }
D3DFORMAT get_pixel_format() { return m_pixformat; }
D3DDISPLAYMODE get_origmode() { return m_origmode; }
UINT32 get_last_texture_flags() { return m_last_texture_flags; }
d3d_texture_manager * get_texture_manager() { return m_texture_manager; }
texture_info * get_default_texture();
texture_info * get_vector_texture();
shaders * get_shaders() { return m_shaders; }
hlsl_options * get_shaders_options() { return m_shaders_options; }
private:
int m_adapter; // ordinal adapter number
int m_width; // current width
int m_height; // current height
int m_refresh; // current refresh rate
int m_create_error_count; // number of consecutive create errors
device * m_device; // pointer to the Direct3DDevice object
int m_gamma_supported; // is full screen gamma supported?
present_parameters m_presentation; // set of presentation parameters
D3DDISPLAYMODE m_origmode; // original display mode for the adapter
D3DFORMAT m_pixformat; // pixel format we are using
vertex_buffer * m_vertexbuf; // pointer to the vertex buffer object
vertex * m_lockedbuf; // pointer to the locked vertex buffer
int m_numverts; // number of accumulated vertices
vertex * m_vectorbatch; // pointer to the vector batch buffer
int m_batchindex; // current index into the vector batch
poly_info m_poly[VERTEX_BUFFER_SIZE/3];// array to hold polygons as they are created
int m_numpolys; // number of accumulated polygons
bool m_restarting; // if we're restarting
int m_mod2x_supported; // is D3DTOP_MODULATE2X supported?
int m_mod4x_supported; // is D3DTOP_MODULATE4X supported?
D3DFORMAT m_screen_format; // format to use for screen textures
texture_info * m_last_texture; // previous texture
UINT32 m_last_texture_flags; // previous texture flags
int m_last_blendenable; // previous blendmode
int m_last_blendop; // previous blendmode
int m_last_blendsrc; // previous blendmode
int m_last_blenddst; // previous blendmode
int m_last_filter; // previous texture filter
UINT32 m_last_wrap; // previous wrap state
int m_last_modmode; // previous texture modulation
void * m_hlsl_buf; // HLSL vertex data
shaders * m_shaders; // HLSL interface
hlsl_options * m_shaders_options; // HLSL options
d3d_texture_manager * m_texture_manager; // texture manager
int m_line_count;
};
#endif // OSD_WINDOWS
#endif // __WIN_DRAWD3D__
|