summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/windows/d3dcomm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/windows/d3dcomm.h')
-rw-r--r--src/osd/windows/d3dcomm.h223
1 files changed, 189 insertions, 34 deletions
diff --git a/src/osd/windows/d3dcomm.h b/src/osd/windows/d3dcomm.h
index 41318dc0822..4516784075a 100644
--- a/src/osd/windows/d3dcomm.h
+++ b/src/osd/windows/d3dcomm.h
@@ -43,56 +43,211 @@
#define __WIN_D3DCOMM__
//============================================================
-// CONSTANTS
+// FORWARD DECLARATIONS
//============================================================
+namespace d3d
+{
+class texture_info;
+class renderer;
//============================================================
// TYPE DEFINITIONS
//============================================================
-/* d3d_texture_info holds information about a texture */
-struct d3d_texture_info
+class vec2f
{
- d3d_texture_info * next; // next texture in the list
- d3d_texture_info * prev; // prev texture in the list
- UINT32 hash; // hash value for the texture
- UINT32 flags; // rendering flags
- render_texinfo texinfo; // copy of the texture info
- float ustart, ustop; // beginning/ending U coordinates
- float vstart, vstop; // beginning/ending V coordinates
- int rawwidth, rawheight; // raw width/height of the texture
- int type; // what type of texture are we?
- int xborderpix; // number of border pixels in X
- int yborderpix; // number of border pixels in Y
- int xprescale; // what is our X prescale factor?
- int yprescale; // what is our Y prescale factor?
- int cur_frame; // what is our current frame?
- int prev_frame; // what was our last frame? (used to determine pause state)
- d3d_texture * d3dtex; // Direct3D texture pointer
- d3d_surface * d3dsurface; // Direct3D offscreen plain surface pointer
- d3d_texture * d3dfinaltex; // Direct3D final (post-scaled) texture
- int target_index; // Direct3D target index
+public:
+ vec2f()
+ {
+ memset(&c, 0, sizeof(float) * 2);
+ }
+ vec2f(float x, float y)
+ {
+ c.x = x;
+ c.y = y;
+ }
+
+ vec2f operator+(const vec2f& a)
+ {
+ return vec2f(c.x + a.c.x, c.y + a.c.y);
+ }
+
+ vec2f operator-(const vec2f& a)
+ {
+ return vec2f(c.x - a.c.x, c.y - a.c.y);
+ }
+
+ struct
+ {
+ float x, y;
+ } c;
};
+class texture_manager
+{
+public:
+ texture_manager() { }
+ texture_manager(renderer *d3d);
+ ~texture_manager() { }
+
+ void update_textures();
+
+ void create_resources();
+ void delete_resources();
+
+ texture_info * find_texinfo(const render_texinfo *texture, UINT32 flags);
+ UINT32 texture_compute_hash(const render_texinfo *texture, UINT32 flags);
+
+ texture_info * get_texlist() { return m_texlist; }
+ void set_texlist(texture_info *texlist) { m_texlist = texlist; }
+ bool is_dynamic_supported() { return (bool)m_dynamic_supported; }
+ void set_dynamic_supported(bool dynamic_supported) { m_dynamic_supported = dynamic_supported; }
+ bool is_stretch_supported() { return (bool)m_stretch_supported; }
+ D3DFORMAT get_yuv_format() { return m_yuv_format; }
+
+ DWORD get_texture_caps() { return m_texture_caps; }
+ DWORD get_max_texture_aspect() { return m_texture_max_aspect; }
+ DWORD get_max_texture_width() { return m_texture_max_width; }
+ DWORD get_max_texture_height() { return m_texture_max_height; }
+
+ texture_info * get_default_texture() { return m_default_texture; }
+ texture_info * get_vector_texture() { return m_vector_texture; }
+
+ renderer * get_d3d() { return m_renderer; }
-/* d3d_poly_info holds information about a single polygon/d3d primitive */
-struct d3d_poly_info
+private:
+ renderer * m_renderer;
+
+ texture_info * m_texlist; // list of active textures
+ int m_dynamic_supported; // are dynamic textures supported?
+ int m_stretch_supported; // is StretchRect with point filtering supported?
+ D3DFORMAT m_yuv_format; // format to use for YUV textures
+
+ DWORD m_texture_caps; // textureCaps field
+ DWORD m_texture_max_aspect; // texture maximum aspect ratio
+ DWORD m_texture_max_width; // texture maximum width
+ DWORD m_texture_max_height; // texture maximum height
+
+ bitmap_argb32 m_vector_bitmap; // experimental: bitmap for vectors
+ texture_info * m_vector_texture; // experimental: texture for vectors
+
+ bitmap_rgb32 m_default_bitmap; // experimental: default bitmap
+ texture_info * m_default_texture; // experimental: default texture
+};
+
+
+/* texture_info holds information about a texture */
+class texture_info
{
- D3DPRIMITIVETYPE type; // type of primitive
- UINT32 count; // total number of primitives
- UINT32 numverts; // total number of vertices
- UINT32 flags; // rendering flags
- DWORD modmode; // texture modulation mode
- d3d_texture_info * texture; // pointer to texture info
- float line_time; // used by vectors
- float line_length; // used by vectors
+public:
+ texture_info(texture_manager *manager, const render_texinfo *texsource, UINT32 flags);
+ ~texture_info();
+
+ render_texinfo & get_texinfo() { return m_texinfo; }
+
+ int get_width() { return m_rawdims.c.x; }
+ int get_height() { return m_rawdims.c.y; }
+ int get_xscale() { return m_xprescale; }
+ int get_yscale() { return m_yprescale; }
+
+ UINT32 get_flags() { return m_flags; }
+
+ void set_data(const render_texinfo *texsource, UINT32 flags);
+
+ texture_info * get_next() { return m_next; }
+ texture_info * get_prev() { return m_prev; }
+
+ UINT32 get_hash() { return m_hash; }
+
+ void set_next(texture_info *next) { m_next = next; }
+ void set_prev(texture_info *prev) { m_prev = prev; }
+
+ bool paused() { return m_cur_frame == m_prev_frame; }
+ void advance_frame() { m_prev_frame = m_cur_frame; }
+ void increment_frame_count() { m_cur_frame++; }
+ void mask_frame_count(int mask) { m_cur_frame %= mask; }
+
+ int get_cur_frame() { return m_cur_frame; }
+ int get_prev_frame() { return m_prev_frame; }
+
+ texture * get_tex() { return m_d3dtex; }
+ surface * get_surface() { return m_d3dsurface; }
+ texture * get_finaltex() { return m_d3dfinaltex; }
+
+ vec2f & get_uvstart() { return m_start; }
+ vec2f & get_uvstop() { return m_stop; }
+ vec2f & get_rawdims() { return m_rawdims; }
+
+private:
+ void prescale();
+ void compute_size(int texwidth, int texheight);
+
+ texture_manager * m_texture_manager; // texture manager pointer
+
+ renderer * m_renderer; // renderer pointer
+
+ texture_info * m_next; // next texture in the list
+ texture_info * m_prev; // prev texture in the list
+
+ UINT32 m_hash; // hash value for the texture
+ UINT32 m_flags; // rendering flags
+ render_texinfo m_texinfo; // copy of the texture info
+ vec2f m_start; // beggining UV coordinates
+ vec2f m_stop; // ending UV coordinates
+ vec2f m_rawdims; // raw dims of the texture
+ int m_type; // what type of texture are we?
+ int m_xborderpix, m_yborderpix; // number of border pixels on X/Y
+ int m_xprescale, m_yprescale; // X/Y prescale factor
+ int m_cur_frame; // what is our current frame?
+ int m_prev_frame; // what was our last frame? (used to determine pause state)
+ texture * m_d3dtex; // Direct3D texture pointer
+ surface * m_d3dsurface; // Direct3D offscreen plain surface pointer
+ texture * m_d3dfinaltex; // Direct3D final (post-scaled) texture
+ int m_target_index; // Direct3D target index
+};
+
+/* d3d::poly_info holds information about a single polygon/d3d primitive */
+class poly_info
+{
+public:
+ poly_info() { }
+
+ void init(D3DPRIMITIVETYPE type, UINT32 count, UINT32 numverts,
+ UINT32 flags, d3d::texture_info *texture, UINT32 modmode);
+ void init(D3DPRIMITIVETYPE type, UINT32 count, UINT32 numverts,
+ UINT32 flags, d3d::texture_info *texture, UINT32 modmode,
+ float line_time, float line_length);
+
+ D3DPRIMITIVETYPE get_type() { return m_type; }
+ UINT32 get_count() { return m_count; }
+ UINT32 get_vertcount() { return m_numverts; }
+ UINT32 get_flags() { return m_flags; }
+
+ d3d::texture_info * get_texture() { return m_texture; }
+ DWORD get_modmode() { return m_modmode; }
+
+ float get_line_time() { return m_line_time; }
+ float get_line_length() { return m_line_length; }
+
+private:
+ D3DPRIMITIVETYPE m_type; // type of primitive
+ UINT32 m_count; // total number of primitives
+ UINT32 m_numverts; // total number of vertices
+ UINT32 m_flags; // rendering flags
+
+ texture_info * m_texture; // pointer to texture info
+ DWORD m_modmode; // texture modulation mode
+
+ float m_line_time; // used by vectors
+ float m_line_length; // used by vectors
};
+}; // d3d
-/* d3d_vertex describes a single vertex */
-struct d3d_vertex
+/* vertex describes a single vertex */
+struct vertex
{
float x, y, z; // X,Y,Z coordinates
float rhw; // RHW when no HLSL, padding when HLSL