summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/windows/drawd3d.c
diff options
context:
space:
mode:
author Ryan Holtz <rholtz@batcountryentertainment.com>2011-06-02 06:22:09 +0000
committer Ryan Holtz <rholtz@batcountryentertainment.com>2011-06-02 06:22:09 +0000
commit844296b795882294f8242ff8eafe2e3bb49b2c10 (patch)
treeea78bc40c1d95bfbd58448f3490684f252d9da66 /src/osd/windows/drawd3d.c
parent6a52f841ebc446cbed863bc96f14ccb5a89b4627 (diff)
Split HLSL code into a separate file, d3dhlsl.c/.h. Also split drawd3d.c into a couple of headers. [Ryan Holtz, Bat Country Entertainment]
Diffstat (limited to 'src/osd/windows/drawd3d.c')
-rw-r--r--src/osd/windows/drawd3d.c2561
1 files changed, 74 insertions, 2487 deletions
diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c
index 512ffd4cf85..89b91aea73e 100644
--- a/src/osd/windows/drawd3d.c
+++ b/src/osd/windows/drawd3d.c
@@ -73,6 +73,8 @@
#include "window.h"
#include "config.h"
#include "strconv.h"
+#include "d3dcomm.h"
+#include "drawd3d.h"
@@ -90,9 +92,6 @@ extern void mtlog_add(const char *event);
#define ENABLE_BORDER_PIX (1)
-#define VERTEX_BASE_FORMAT (D3DFVF_DIFFUSE | D3DFVF_TEX1)
-#define VERTEX_BUFFER_SIZE (2048*4+4)
-
enum
{
TEXTURE_TYPE_PLAIN,
@@ -111,325 +110,10 @@ enum
//============================================================
-// TYPE DEFINITIONS
-//============================================================
-
-/* texture_info holds information about a texture */
-typedef struct _texture_info texture_info;
-struct _texture_info
-{
- texture_info * next; // next texture in the list
- 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?
- 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
-};
-
-
-/* poly_info holds information about a single polygon/d3d primitive */
-typedef struct _poly_info poly_info;
-struct _poly_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
- texture_info * texture; // pointer to texture info
-};
-
-
-/* d3d_vertex describes a single vertex */
-typedef struct _d3d_vertex d3d_vertex;
-struct _d3d_vertex
-{
- float x, y, z; // X,Y,Z coordinates
- float rhw; // RHW when no HLSL, padding when HLSL
- D3DCOLOR color; // diffuse color
- float u0, v0; // texture stage 0 coordinates
-};
-
-/* d3d_options is the information about runtime-mutable Direct3D options */
-typedef struct _d3d_options d3d_options;
-struct _d3d_options
-{
- float screen_shadow_mask_alpha;
- int screen_shadow_mask_count_x;
- int screen_shadow_mask_count_y;
- float screen_shadow_mask_u_size;
- float screen_shadow_mask_v_size;
- float screen_curvature;
- float screen_pincushion;
- float screen_scanline_alpha;
- float screen_scanline_scale;
- float screen_scanline_height;
- float screen_scanline_bright_scale;
- float screen_scanline_bright_offset;
- float screen_scanline_offset;
- float screen_defocus_x;
- float screen_defocus_y;
- float screen_red_converge_x;
- float screen_red_converge_y;
- float screen_green_converge_x;
- float screen_green_converge_y;
- float screen_blue_converge_x;
- float screen_blue_converge_y;
- float screen_red_radial_converge_x;
- float screen_red_radial_converge_y;
- float screen_green_radial_converge_x;
- float screen_green_radial_converge_y;
- float screen_blue_radial_converge_x;
- float screen_blue_radial_converge_y;
- float screen_red_from_red;
- float screen_red_from_green;
- float screen_red_from_blue;
- float screen_green_from_red;
- float screen_green_from_green;
- float screen_green_from_blue;
- float screen_blue_from_red;
- float screen_blue_from_green;
- float screen_blue_from_blue;
- float screen_red_offset;
- float screen_green_offset;
- float screen_blue_offset;
- float screen_red_scale;
- float screen_green_scale;
- float screen_blue_scale;
- float screen_red_power;
- float screen_green_power;
- float screen_blue_power;
- float screen_red_floor;
- float screen_green_floor;
- float screen_blue_floor;
- float screen_red_phosphor_life;
- float screen_green_phosphor_life;
- float screen_blue_phosphor_life;
- float screen_saturation;
-};
-
-static d3d_options g_d3d_hlsl_presets[6] =
-{
- { 0.00f, 1, 1, 0.1875f, 0.1875f,
- 0.03f, 0.03f,
- 0.25f, 1.0f, 1.0f, 0.6f, 0.0f,
- 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
- 0.0f, 0.0f, 0.0f,
- 1.1f, 1.1f, 1.1f,
- 0.9f, 0.9f, 0.9f,
- 0.05f, 0.05f, 0.05f,
- 0.45f, 0.45f, 0.45f,
- 1.4f },
- { 0.15f, 512, 384, 0.1875f, 0.1875f,
- 0.03f, 0.03f,
- 0.25f, 1.0f, 1.0f, 0.6f, 0.0f,
- 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
- 0.0f, 0.0f, 0.0f,
- 1.1f, 1.1f, 1.1f,
- 0.9f, 0.9f, 0.9f,
- 0.05f, 0.05f, 0.05f,
- 0.45f, 0.45f, 0.45f,
- 1.4f },
- { 0.15f, 512, 384, 0.1875f, 0.1875f,
- 0.03f, 0.03f,
- 0.25f, 1.0f, 1.0f, 0.6f, 0.0f,
- 0.0f, 0.0f,
- 0.4f, 0.1f, 0.0, 0.0f,-0.25f,-0.3f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
- 0.0f, 0.0f, 0.0f,
- 1.1f, 1.1f, 1.1f,
- 0.9f, 0.9f, 0.9f,
- 0.05f, 0.05f, 0.05f,
- 0.45f, 0.45f, 0.45f,
- 1.4f },
- { 0.15f, 512, 384, 0.1875f, 0.1875f,
- 0.03f, 0.03f,
- 0.25f, 1.0f, 1.0f, 0.6f, 0.0f,
- 0.0f, 0.0f,
- 0.4f, 0.1f, 0.0, 0.0f,-0.25f,-0.3f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
- 0.0f, 0.0f, 0.0f,
- 1.0f, 1.0f, 1.0f,
- 1.0f, 1.0f, 1.0f,
- 0.05f, 0.05f, 0.05f,
- 0.45f, 0.45f, 0.45f,
- 1.0f },
- { 0.15f, 512, 384, 0.1875f, 0.1875f,
- 0.03f, 0.03f,
- 0.25f, 1.0f, 1.0f, 0.6f, 0.0f,
- 0.0f, 0.0f,
- 0.4f, 0.1f, 0.0, 0.0f,-0.25f,-0.3f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
- 0.0f, 0.0f, 0.0f,
- 1.0f, 1.0f, 1.0f,
- 1.0f, 1.0f, 1.0f,
- 0.05f, 0.05f, 0.05f,
- 0.45f, 0.45f, 0.45f,
- 0.8f },
- { 0.15f, 512, 384, 0.1875f, 0.1875f,
- 0.03f, 0.03f,
- 0.25f, 1.0f, 1.0f, 0.6f, 0.0f,
- 0.0f, 0.0f,
- 0.4f, 0.1f, 0.0, 0.0f,-0.25f,-0.3f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.7f, 0.3f, 0.0f, 0.0f, 0.7f, 0.3f, 0.3f, 0.0f, 0.7f,
- 0.0f, 0.0f, 0.0f,
- 1.0f, 1.0f, 1.0f,
- 1.0f, 1.0f, 1.0f,
- 0.05f, 0.05f, 0.05f,
- 0.45f, 0.45f, 0.45f,
- 0.8f }
-};
-
-/* d3d_info is the information about Direct3D for the current screen */
-typedef struct _d3d_info d3d_info;
-struct _d3d_info
-{
- int adapter; // ordinal adapter number
- int width, height; // current width, height
- int refresh; // current refresh rate
- int create_error_count; // number of consecutive create errors
-
- win_window_info * window; // current window info
-
- d3d_device * device; // pointer to the Direct3DDevice object
- int gamma_supported; // is full screen gamma supported?
- d3d_present_parameters presentation; // set of presentation parameters
- D3DDISPLAYMODE origmode; // original display mode for the adapter
- D3DFORMAT pixformat; // pixel format we are using
-
- d3d_vertex_buffer * vertexbuf; // pointer to the vertex buffer object
- d3d_vertex * lockedbuf; // pointer to the locked vertex buffer
- int numverts; // number of accumulated vertices
-
- d3d_effect * effect; // pointer to the current effect object
- d3d_effect * prescale_effect; // pointer to the current prescale-effect object
- d3d_effect * post_effect; // pointer to the current post-effect object
- d3d_effect * pincushion_effect; // pointer to the current pincushion-effect object
- d3d_effect * focus_effect; // pointer to the current focus-effect object
- d3d_effect * phosphor_effect; // pointer to the current phosphor-effect object
- d3d_effect * deconverge_effect; // pointer to the current deconvergence-effect object
- d3d_effect * color_effect; // pointer to the current color-effect object
- d3d_effect * yiq_encode_effect; // pointer to the current YIQ encoder effect object
- d3d_effect * yiq_decode_effect; // pointer to the current YIQ decoder effect object
- d3d_vertex * fsfx_vertices; // pointer to our full-screen-quad object
-
- poly_info poly[VERTEX_BUFFER_SIZE / 3];// array to hold polygons as they are created
- int numpolys; // number of accumulated polygons
-
- texture_info * texlist; // list of active textures
- int dynamic_supported; // are dynamic textures supported?
- int stretch_supported; // is StretchRect with point filtering supported?
- int mod2x_supported; // is D3DTOP_MODULATE2X supported?
- int mod4x_supported; // is D3DTOP_MODULATE4X supported?
- D3DFORMAT screen_format; // format to use for screen textures
- D3DFORMAT yuv_format; // format to use for YUV textures
-
- DWORD texture_caps; // textureCaps field
- DWORD texture_max_aspect; // texture maximum aspect ratio
- DWORD texture_max_width; // texture maximum width
- DWORD texture_max_height; // texture maximum height
-
- texture_info * last_texture; // previous texture
- UINT32 last_texture_flags; // previous texture flags
- int last_blendenable; // previous blendmode
- int last_blendop; // previous blendmode
- int last_blendsrc; // previous blendmode
- int last_blenddst; // previous blendmode
- int last_filter; // previous texture filter
- int last_wrap; // previous wrap state
- DWORD last_modmode; // previous texture modulation
-
- bitmap_t * vector_bitmap; // experimental: bitmap for vectors
- texture_info * vector_texture; // experimental: texture for vectors
-
- bitmap_t * default_bitmap; // experimental: default bitmap
- texture_info * default_texture; // experimental: default texture
-
- bool hlsl_enable; // HLSL enable flag
- bool yiq_enable; // HLSL YIQ-convolution flag
- int hlsl_prescale_size; // HLSL prescale size
- int hlsl_preset; // HLSL preset, if relevant
- bitmap_t * shadow_bitmap; // shadow mask bitmap for post-processing shader
- texture_info * shadow_texture; // shadow mask texture for post-processing shader
- int registered_targets; // Number of registered HLSL targets (i.e., screens)
- d3d_options * hlsl_options; // HLSL uniforms
- avi_file * hlsl_avi_file; // HLSL AVI file
- bitmap_t * hlsl_avi_snap; // HLSL AVI snapshot
- int hlsl_avi_frame; // HLSL AVI frame
- attotime hlsl_avi_frame_period; // HLSL AVI frame period
- attotime hlsl_avi_next_frame_time; // HLSL AVI next frame time
- d3d_surface * hlsl_avi_copy_surface; // HLSL AVI destination surface in system memory
- d3d_texture * hlsl_avi_copy_texture; // HLSL AVI destination texture in system memory
- d3d_surface * hlsl_avi_final_target; // HLSL AVI upscaled surface
- d3d_texture * hlsl_avi_final_texture; // HLSL AVI upscaled texture
- bool hlsl_render_snap; // whether or not to take HLSL post-render snapshot
- bool hlsl_snap_rendered; // whether we just rendered our HLSL post-render shot or not
- d3d_surface * hlsl_snap_copy_target; // HLSL snapshot destination surface in system memory
- d3d_texture * hlsl_snap_copy_texture; // HLSL snapshot destination surface in system memory
- d3d_surface * hlsl_snap_target; // HLSL snapshot upscaled surface
- d3d_texture * hlsl_snap_texture; // HLSL snapshot upscaled texture
- int hlsl_snap_width; // HLSL snapshot width
- int hlsl_snap_height; // HLSL snapshot height
-
- // HLSL render targets
- int target_use_count[9]; // Whether or not a target has been used yet
- texture_info * target_in_use[9]; // Target texture that is currently in use
- d3d_surface * last_hlsltarget[9]; // HLSL render target surface pointer for each screen's previous frame
- d3d_texture * last_hlsltexture[9]; // HLSL render target texture pointer for each screen's previous frame
- d3d_surface * hlslprescaletarget0[9]; // Direct3D render target surface pointer (prescale, if necessary)
- d3d_surface * hlsltarget0[9]; // HLSL render target surface pointer (pass 0, if necessary)
- d3d_surface * hlsltarget1[9]; // HLSL render target surface pointer (pass 1, if necessary)
- d3d_surface * hlsltarget2[9]; // HLSL render target surface pointer (pass 2, if necessary)
- d3d_surface * hlsltarget3[9]; // HLSL render target surface pointer (pass 3, if necessary)
- d3d_surface * hlsltarget4[9]; // HLSL render target surface pointer (pass 4, if necessary)
- d3d_surface * hlslsmalltarget0[9]; // HLSL render target surface pointer (small pass 0, if necessary)
- d3d_texture * hlslprescaletexture0[9]; // HLSL render target surface pointer (prescale, if necessary)
- d3d_texture * hlsltexture0[9]; // HLSL render target texture pointer (pass 0, if necessary)
- d3d_texture * hlsltexture1[9]; // HLSL render target texture pointer (pass 1, if necessary)
- d3d_texture * hlsltexture2[9]; // HLSL render target texture pointer (pass 2, if necessary)
- d3d_texture * hlsltexture3[9]; // HLSL render target texture pointer (pass 3, if necessary)
- d3d_texture * hlsltexture4[9]; // HLSL render target texture pointer (pass 4, if necessary)
- d3d_texture * hlslsmalltexture0[9]; // HLSL render target texture pointer (small pass 0, if necessary)
-};
-
-
-/* line_aa_step is used for drawing antialiased lines */
-typedef struct _line_aa_step line_aa_step;
-struct _line_aa_step
-{
- float xoffs, yoffs; // X/Y deltas
- float weight; // weight contribution
-};
-
-
-
-//============================================================
// GLOBALS
//============================================================
-static d3d * d3dintf;
+static d3d * d3dintf; // FIX ME
static const line_aa_step line_aa_1step[] =
{
@@ -446,389 +130,6 @@ static const line_aa_step line_aa_4step[] =
{ 0 }
};
-/*-------------------------------------------------
- slider_alloc - allocate a new slider entry
- currently duplicated from ui.c, this could
- be done in a more ideal way.
--------------------------------------------------*/
-
-static slider_state *slider_alloc(running_machine &machine, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, slider_update update, void *arg)
-{
- int size = sizeof(slider_state) + strlen(title);
- slider_state *state = (slider_state *)auto_alloc_array_clear(machine, UINT8, size);
-
- state->minval = minval;
- state->defval = defval;
- state->maxval = maxval;
- state->incval = incval;
- state->update = update;
- state->arg = arg;
- strcpy(state->description, title);
-
- return state;
-}
-
-
-//============================================================
-// assorted slider accessors
-//============================================================
-
-static slider_state *slider_list;
-
-static INT32 slider_set(float *option, float scale, const char *fmt, astring *string, INT32 newval)
-{
- if (option != NULL && newval != SLIDER_NOCHANGE) *option = (float)newval * scale;
- if (string != NULL) string->printf(fmt, *option);
- return floor(*option / scale + 0.5f);
-}
-
-static INT32 slider_shadow_mask_alpha(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_shadow_mask_alpha), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_shadow_mask_x_count(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- d3d_options *options = ((d3d_info*)arg)->hlsl_options;
- if (newval != SLIDER_NOCHANGE) options->screen_shadow_mask_count_x = newval;
- if (string != NULL) string->printf("%d", options->screen_shadow_mask_count_x);
- return options->screen_shadow_mask_count_x;
-}
-
-static INT32 slider_shadow_mask_y_count(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- d3d_options *options = ((d3d_info*)arg)->hlsl_options;
- if (newval != SLIDER_NOCHANGE) options->screen_shadow_mask_count_y = newval;
- if (string != NULL) string->printf("%d", options->screen_shadow_mask_count_y);
- return options->screen_shadow_mask_count_y;
-}
-
-static INT32 slider_shadow_mask_usize(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_shadow_mask_u_size), 1.0f / 32.0f, "%2.5f", string, newval);
-}
-
-static INT32 slider_shadow_mask_vsize(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_shadow_mask_v_size), 1.0f / 32.0f, "%2.5f", string, newval);
-}
-
-static INT32 slider_curvature(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_curvature), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_pincushion(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_pincushion), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_scanline_alpha(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_scanline_alpha), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_scanline_scale(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_scanline_scale), 0.05f, "%2.2f", string, newval);
-}
-
-static INT32 slider_scanline_height(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_scanline_height), 0.05f, "%2.2f", string, newval);
-}
-
-static INT32 slider_scanline_bright_scale(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_scanline_bright_scale), 0.05f, "%2.2f", string, newval);
-}
-
-static INT32 slider_scanline_bright_offset(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_scanline_bright_offset), 0.05f, "%2.2f", string, newval);
-}
-
-static INT32 slider_scanline_offset(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_scanline_offset), 0.05f, "%2.2f", string, newval);
-}
-
-static INT32 slider_defocus_x(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_defocus_x), 0.5f, "%2.1f", string, newval);
-}
-
-static INT32 slider_defocus_y(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_defocus_y), 0.5f, "%2.1f", string, newval);
-}
-
-static INT32 slider_red_converge_x(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_converge_x), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_red_converge_y(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_converge_y), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_green_converge_x(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_converge_x), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_green_converge_y(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_converge_y), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_blue_converge_x(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_converge_x), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_blue_converge_y(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_converge_y), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_red_radial_converge_x(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_radial_converge_x), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_red_radial_converge_y(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_radial_converge_y), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_green_radial_converge_x(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_radial_converge_x), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_green_radial_converge_y(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_radial_converge_y), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_blue_radial_converge_x(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_radial_converge_x), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_blue_radial_converge_y(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_radial_converge_y), 0.1f, "%3.1f", string, newval);
-}
-
-static INT32 slider_red_from_r(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_from_red), 0.005f, "%2.3f", string, newval);
-}
-
-static INT32 slider_red_from_g(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_from_green), 0.005f, "%2.3f", string, newval);
-}
-
-static INT32 slider_red_from_b(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_from_blue), 0.005f, "%2.3f", string, newval);
-}
-
-static INT32 slider_green_from_r(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_from_red), 0.005f, "%2.3f", string, newval);
-}
-
-static INT32 slider_green_from_g(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_from_green), 0.005f, "%2.3f", string, newval);
-}
-
-static INT32 slider_green_from_b(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_from_blue), 0.005f, "%2.3f", string, newval);
-}
-
-static INT32 slider_blue_from_r(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_from_red), 0.005f, "%2.3f", string, newval);
-}
-
-static INT32 slider_blue_from_g(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_from_green), 0.005f, "%2.3f", string, newval);
-}
-
-static INT32 slider_blue_from_b(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_from_blue), 0.005f, "%2.3f", string, newval);
-}
-
-static INT32 slider_red_offset(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_offset), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_green_offset(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_offset), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_blue_offset(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_offset), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_red_scale(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_scale), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_green_scale(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_scale), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_blue_scale(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_scale), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_red_power(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_power), 0.05f, "%2.2f", string, newval);
-}
-
-static INT32 slider_green_power(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_power), 0.05f, "%2.2f", string, newval);
-}
-
-static INT32 slider_blue_power(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_power), 0.05f, "%2.2f", string, newval);
-}
-
-static INT32 slider_red_floor(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_floor), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_green_floor(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_floor), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_blue_floor(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_floor), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_red_phosphor_life(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_red_phosphor_life), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_green_phosphor_life(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_green_phosphor_life), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_blue_phosphor_life(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_blue_phosphor_life), 0.01f, "%2.2f", string, newval);
-}
-
-static INT32 slider_saturation(running_machine &machine, void *arg, astring *string, INT32 newval)
-{
- return slider_set(&(((d3d_info*)arg)->hlsl_options->screen_saturation), 0.01f, "%2.2f", string, newval);
-}
-
-//============================================================
-// init_slider_list
-//============================================================
-
-static slider_state *init_slider_list(d3d_info *d3d)
-{
- slider_state *listhead = NULL;
- slider_state **tailptr = &listhead;
- astring string;
-
- if(!d3d->hlsl_enable || !d3dintf->post_fx_available)
- {
- slider_list = NULL;
- return NULL;
- }
-
- *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask Darkness", 0, 0, 100, 1, slider_shadow_mask_alpha, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask X Count", 1, 640, 1024, 1, slider_shadow_mask_x_count, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask Y Count", 1, 480, 1024, 1, slider_shadow_mask_y_count, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask Pixel Count X", 1, 3, 32, 1, slider_shadow_mask_usize, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask Pixel Count Y", 1, 3, 32, 1, slider_shadow_mask_vsize, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Screen Curvature", 0, 0, 100, 1, slider_curvature, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Image Pincushion", 0, 0, 100, 1, slider_pincushion, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Scanline Darkness", 0, 0, 100, 1, slider_scanline_alpha, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Scanline Screen Height", 1, 20, 80, 1, slider_scanline_scale, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Scanline Indiv. Height", 1, 10, 80, 1, slider_scanline_height, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Scanline Brightness", 0, 20, 40, 1, slider_scanline_bright_scale, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Scanline Brightness Overdrive", 0, 12, 20, 1, slider_scanline_bright_offset, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Scanline Jitter", 0, 0, 40, 1, slider_scanline_offset, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Defocus X", 0, 0, 64, 1, slider_defocus_x, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Defocus Y", 0, 0, 64, 1, slider_defocus_y, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Position Offset X", -1500, 0, 1500, 1, slider_red_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Position Offset Y", -1500, 0, 1500, 1, slider_red_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Position Offset X", -1500, 0, 1500, 1, slider_green_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Position Offset Y", -1500, 0, 1500, 1, slider_green_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Position Offset X", -1500, 0, 1500, 1, slider_blue_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Position Offset Y", -1500, 0, 1500, 1, slider_blue_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Convergence X", -1500, 0, 1500, 1, slider_red_radial_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Convergence Y", -1500, 0, 1500, 1, slider_red_radial_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Convergence X", -1500, 0, 1500, 1, slider_green_radial_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Convergence Y", -1500, 0, 1500, 1, slider_green_radial_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Convergence X", -1500, 0, 1500, 1, slider_blue_radial_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Convergence Y", -1500, 0, 1500, 1, slider_blue_radial_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Output from Red Input", -400, 0, 400, 5, slider_red_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Output from Green Input", -400, 0, 400, 5, slider_red_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Output from Blue Input", -400, 0, 400, 5, slider_red_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Output from Red Input", -400, 0, 400, 5, slider_green_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Output from Green Input", -400, 0, 400, 5, slider_green_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Output from Blue Input", -400, 0, 400, 5, slider_green_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Output from Red Input", -400, 0, 400, 5, slider_blue_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Output from Green Input", -400, 0, 400, 5, slider_blue_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Output from Blue Input", -400, 0, 400, 5, slider_blue_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red DC Offset", -100, 0, 100, 1, slider_red_offset, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green DC Offset", -100, 0, 100, 1, slider_green_offset, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue DC Offset", -100, 0, 100, 1, slider_blue_offset, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Scale", -200, 100, 200, 1, slider_red_scale, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Scale", -200, 100, 200, 1, slider_green_scale, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Scale", -200, 100, 200, 1, slider_blue_scale, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Power", -80, 20, 80, 1, slider_red_power, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Power", -80, 20, 80, 1, slider_green_power, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Power", -80, 20, 80, 1, slider_blue_power, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Floor", 0, 0, 100, 1, slider_red_floor, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Floor", 0, 0, 100, 1, slider_green_floor, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Floor", 0, 0, 100, 1, slider_blue_floor, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Red Phosphor Life", 0, 0, 100, 1, slider_red_phosphor_life, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Green Phosphor Life", 0, 0, 100, 1, slider_green_phosphor_life, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Blue Phosphor Life", 0, 0, 100, 1, slider_blue_phosphor_life, (void*)d3d); tailptr = &(*tailptr)->next;
- *tailptr = slider_alloc(d3d->window->machine(), "Saturation", 0, 100, 400, 1, slider_saturation, (void*)d3d); tailptr = &(*tailptr)->next;
-
- return listhead;
-}
-
-//============================================================
-// get_slider_list
-//============================================================
-
-void *windows_osd_interface::get_slider_list()
-{
- return (void*)slider_list;
-}
-
//============================================================
// INLINES
//============================================================
@@ -908,7 +209,7 @@ INLINE UINT32 texture_compute_hash(const render_texinfo *texture, UINT32 flags)
}
-INLINE void set_texture(d3d_info *d3d, texture_info *texture)
+INLINE void set_texture(d3d_info *d3d, d3d_texture_info *texture)
{
HRESULT result;
if (texture != d3d->last_texture)
@@ -916,19 +217,8 @@ INLINE void set_texture(d3d_info *d3d, texture_info *texture)
d3d->last_texture = texture;
d3d->last_texture_flags = (texture == NULL ? 0 : texture->flags);
result = (*d3dintf->device.set_texture)(d3d->device, 0, (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
- if(d3d->hlsl_enable && d3d->effect != NULL)
- {
- (*d3dintf->effect.set_texture)(d3d->effect, "Diffuse", (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
- if(d3d->yiq_enable)
- {
- (*d3dintf->effect.set_texture)(d3d->yiq_encode_effect, "Diffuse", (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
- }
- else
- {
- (*d3dintf->effect.set_texture)(d3d->color_effect, "Diffuse", (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
- }
- (*d3dintf->effect.set_texture)(d3d->pincushion_effect, "Diffuse", (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
- }
+ if (d3d->hlsl != NULL)
+ d3d->hlsl->set_texture(texture);
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_texture call\n", (int)result);
}
}
@@ -1036,7 +326,7 @@ INLINE void set_blendmode(d3d_info *d3d, int blendmode)
INLINE void reset_render_states(d3d_info *d3d)
{
// this ensures subsequent calls to the above setters will force-update the data
- d3d->last_texture = (texture_info *)~0;
+ d3d->last_texture = (d3d_texture_info *)~0;
d3d->last_filter = -1;
d3d->last_blendenable = -1;
d3d->last_blendop = -1;
@@ -1077,28 +367,18 @@ static int update_window_size(win_window_info *window);
// drawing
static void draw_line(d3d_info *d3d, const render_primitive *prim);
static void draw_quad(d3d_info *d3d, const render_primitive *prim);
-static void init_fsfx_quad(d3d_info *d3d);
// primitives
static d3d_vertex *primitive_alloc(d3d_info *d3d, int numverts);
static void primitive_flush_pending(d3d_info *d3d);
// textures
-static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsource, UINT32 flags);
-static void texture_compute_size(d3d_info *d3d, int texwidth, int texheight, texture_info *texture);
-static void texture_set_data(d3d_info *d3d, texture_info *texture, const render_texinfo *texsource, UINT32 flags);
-static void texture_prescale(d3d_info *d3d, texture_info *texture);
-static texture_info *texture_find(d3d_info *d3d, const render_primitive *prim);
+static void texture_compute_size(d3d_info *d3d, int texwidth, int texheight, d3d_texture_info *texture);
+static void texture_set_data(d3d_info *d3d, d3d_texture_info *texture, const render_texinfo *texsource, UINT32 flags);
+static void texture_prescale(d3d_info *d3d, d3d_texture_info *texture);
+static d3d_texture_info *texture_find(d3d_info *d3d, const render_primitive *prim);
static void texture_update(d3d_info *d3d, const render_primitive *prim);
-// logging
-static void end_hlsl_avi_recording(d3d_info *d3d);
-static void hlsl_render_snapshot(d3d_info *d3d, d3d_surface *surface);
-static void begin_hlsl_avi_recording(d3d_info *d3d, const char *name);
-static void hlsl_record_texture(d3d_info *d3d, d3d_surface *surface);
-static file_error open_next(d3d_info *d3d, emu_file &file, const char *extension, int idx);
-
-
//============================================================
// drawd3d_init
//============================================================
@@ -1162,7 +442,7 @@ static int drawd3d_window_init(win_window_info *window)
d3d = global_alloc_clear(d3d_info);
window->drawdata = d3d;
d3d->window = window;
- d3d->hlsl_options = NULL;
+ d3d->hlsl = NULL;
// experimental: load a PNG to use for vector rendering; it is treated
// as a brightness map
@@ -1174,8 +454,6 @@ static int drawd3d_window_init(win_window_info *window)
d3d->vector_bitmap = render_load_png(file, NULL, "vector.png", d3d->vector_bitmap, NULL);
}
- d3d->shadow_texture = NULL;
-
d3d->default_bitmap = auto_bitmap_alloc(window->machine(), 8, 8, BITMAP_FORMAT_RGB32);
bitmap_fill(d3d->default_bitmap, NULL, MAKE_ARGB(0xff,0xff,0xff,0xff));
@@ -1197,58 +475,20 @@ error:
-//============================================================
-// drawd3d_window_save
-//============================================================
-
-static void drawd3d_window_save(win_window_info *window)
+static void drawd3d_window_record(win_window_info *window)
{
d3d_info *d3d = (d3d_info *)window->drawdata;
- if (!d3d->hlsl_enable || !d3dintf->post_fx_available)
- return;
-
- HRESULT result = (*d3dintf->device.create_texture)(d3d->device, d3d->hlsl_snap_width, d3d->hlsl_snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &d3d->hlsl_snap_copy_texture);
- if (result != D3D_OK)
- {
- mame_printf_verbose("Direct3D: Unable to init system-memory target for HLSL snapshot (%08x), bailing\n", (UINT32)result);
- return;
- }
- (*d3dintf->texture.get_surface_level)(d3d->hlsl_snap_copy_texture, 0, &d3d->hlsl_snap_copy_target);
-
- result = (*d3dintf->device.create_texture)(d3d->device, d3d->hlsl_snap_width, d3d->hlsl_snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsl_snap_texture);
- if (result != D3D_OK)
- {
- mame_printf_verbose("Direct3D: Unable to init video-memory target for HLSL snapshot (%08x), bailing\n", (UINT32)result);
- return;
- }
- (*d3dintf->texture.get_surface_level)(d3d->hlsl_snap_texture, 0, &d3d->hlsl_snap_target);
-
- d3d->hlsl_render_snap = true;
- d3d->hlsl_snap_rendered = false;
+ if (d3d->hlsl != NULL)
+ d3d->hlsl->window_record();
}
-static void drawd3d_window_record(win_window_info *window)
+static void drawd3d_window_save(win_window_info *window)
{
d3d_info *d3d = (d3d_info *)window->drawdata;
- if (!d3d->hlsl_enable || !d3dintf->post_fx_available)
- return;
-
- windows_options &options = downcast<windows_options &>(window->machine().options());
- const char *filename = options.d3d_hlsl_write();
-
- if(d3d->hlsl_avi_file != NULL)
- {
- end_hlsl_avi_recording(d3d);
- }
- else
- {
- if (filename[0] != 0)
- {
- begin_hlsl_avi_recording(d3d, filename);
- }
- }
+ if (d3d->hlsl != NULL)
+ d3d->hlsl->window_save();
}
@@ -1260,7 +500,8 @@ static void drawd3d_window_destroy(win_window_info *window)
{
d3d_info *d3d = (d3d_info *)window->drawdata;
- end_hlsl_avi_recording(d3d);
+ if (d3d->hlsl->recording())
+ d3d->hlsl->window_record();
// skip if nothing
if (d3d == NULL)
@@ -1273,13 +514,6 @@ static void drawd3d_window_destroy(win_window_info *window)
global_free(d3d->vector_bitmap);
d3d->vector_bitmap = NULL;
- // experimental: free the shadow PNG
- if(d3d->hlsl_enable && d3d->shadow_bitmap != NULL)
- {
- global_free(d3d->shadow_bitmap);
- d3d->shadow_bitmap = NULL;
- }
-
// free the memory in the window
global_free(d3d);
window->drawdata = NULL;
@@ -1349,7 +583,7 @@ mtlog_add("drawd3d_window_draw: begin");
result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
- hlsl_record_texture(d3d, d3d->hlsl_avi_final_target);
+ d3d->hlsl->record_texture();
// first update any textures
window->primlist->acquire_lock();
@@ -1365,9 +599,10 @@ mtlog_add("drawd3d_window_draw: begin_scene");
d3d->lockedbuf = NULL;
// loop over primitives
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
+ if(d3d->hlsl->enabled())
{
- init_fsfx_quad(d3d);
+ d3d->hlsl_buf = (void*)primitive_alloc(d3d, 4);
+ d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
}
mtlog_add("drawd3d_window_draw: primitive loop begin");
@@ -1405,10 +640,7 @@ mtlog_add("drawd3d_window_draw: present begin");
mtlog_add("drawd3d_window_draw: present end");
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device present call\n", (int)result);
- if(d3d->hlsl_render_snap && d3d->hlsl_snap_rendered)
- {
- hlsl_render_snapshot(d3d, d3d->hlsl_snap_target);
- }
+ d3d->hlsl->frame_complete();
return 0;
}
@@ -1518,9 +750,6 @@ try_again:
d3d->create_error_count = 0;
mame_printf_verbose("Direct3D: Device created at %dx%d\n", d3d->width, d3d->height);
- d3d->hlsl_snap_width = downcast<windows_options &>(d3d->window->machine().options()).d3d_snap_width();
- d3d->hlsl_snap_height = downcast<windows_options &>(d3d->window->machine().options()).d3d_snap_height();
-
// set the max texture size
window->target->set_max_texture_size(d3d->texture_max_width, d3d->texture_max_height);
mame_printf_verbose("Direct3D: Max texture size = %dx%d\n", (int)d3d->texture_max_width, (int)d3d->texture_max_height);
@@ -1551,153 +780,26 @@ try_again:
}
}
- // experimental: initialize some more things if we're using HLSL
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
+ if (d3d->default_bitmap != NULL)
{
- const char *fx_dir = downcast<windows_options &>(window->machine().options()).screen_post_fx_dir();
- char primary_name_cstr[1024];
- char post_name_cstr[1024];
- char prescale_name_cstr[1024];
- char pincushion_name_cstr[1024];
- char phosphor_name_cstr[1024];
- char focus_name_cstr[1024];
- char deconverge_name_cstr[1024];
- char color_name_cstr[1024];
- char yiq_encode_name_cstr[1024];
- char yiq_decode_name_cstr[1024];
-
- sprintf(primary_name_cstr, "%s\\primary.fx", fx_dir);
- TCHAR *primary_name = tstring_from_utf8(primary_name_cstr);
-
- sprintf(post_name_cstr, "%s\\post.fx", fx_dir);
- TCHAR *post_name = tstring_from_utf8(post_name_cstr);
-
- sprintf(prescale_name_cstr, "%s\\prescale.fx", fx_dir);
- TCHAR *prescale_name = tstring_from_utf8(prescale_name_cstr);
-
- sprintf(pincushion_name_cstr, "%s\\pincushion.fx", fx_dir);
- TCHAR *pincushion_name = tstring_from_utf8(pincushion_name_cstr);
-
- sprintf(phosphor_name_cstr, "%s\\phosphor.fx", fx_dir);
- TCHAR *phosphor_name = tstring_from_utf8(phosphor_name_cstr);
-
- sprintf(focus_name_cstr, "%s\\focus.fx", fx_dir);
- TCHAR *focus_name = tstring_from_utf8(focus_name_cstr);
-
- sprintf(deconverge_name_cstr, "%s\\deconverge.fx", fx_dir);
- TCHAR *deconverge_name = tstring_from_utf8(deconverge_name_cstr);
-
- sprintf(color_name_cstr, "%s\\color.fx", fx_dir);
- TCHAR *color_name = tstring_from_utf8(color_name_cstr);
-
- sprintf(yiq_encode_name_cstr, "%s\\yiq_encode.fx", fx_dir);
- TCHAR *yiq_encode_name = tstring_from_utf8(yiq_encode_name_cstr);
-
- sprintf(yiq_decode_name_cstr, "%s\\yiq_decode.fx", fx_dir);
- TCHAR *yiq_decode_name = tstring_from_utf8(yiq_decode_name_cstr);
-
- // create the regular shader
- result = (*d3dintf->device.create_effect)(d3d->device, primary_name, &d3d->effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load primary.fx\n");
- return 1;
- }
-
- // create the post-processing shader
- result = (*d3dintf->device.create_effect)(d3d->device, post_name, &d3d->post_effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load post.fx\n");
- return 1;
- }
-
- // create the prescaling shader
- result = (*d3dintf->device.create_effect)(d3d->device, prescale_name, &d3d->prescale_effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load prescale.fx\n");
- return 1;
- }
-
- // create the pincushion shader
- result = (*d3dintf->device.create_effect)(d3d->device, pincushion_name, &d3d->pincushion_effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load pincushion.fx\n");
- return 1;
- }
-
- // create the phosphor shader
- result = (*d3dintf->device.create_effect)(d3d->device, phosphor_name, &d3d->phosphor_effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load phosphor.fx\n");
- return 1;
- }
-
- // create the focus shader
- result = (*d3dintf->device.create_effect)(d3d->device, focus_name, &d3d->focus_effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load focus.fx\n");
- return 1;
- }
-
- // create the deconvergence shader
- result = (*d3dintf->device.create_effect)(d3d->device, deconverge_name, &d3d->deconverge_effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load deconverge.fx\n");
- return 1;
- }
-
- // create the color convolution shader
- result = (*d3dintf->device.create_effect)(d3d->device, color_name, &d3d->color_effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load color.fx\n");
- return 1;
- }
-
- // create the YIQ modulation shader
- result = (*d3dintf->device.create_effect)(d3d->device, yiq_encode_name, &d3d->yiq_encode_effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load yiq_encode.fx\n");
- return 1;
- }
+ render_texinfo texture;
- // create the YIQ demodulation shader
- result = (*d3dintf->device.create_effect)(d3d->device, yiq_decode_name, &d3d->yiq_decode_effect);
- if(result != D3D_OK)
- {
- printf("Direct3D: Unable to load yiq_decode.fx\n");
- return 1;
- }
+ // fake in the basic data so it looks like it came from render.c
+ texture.base = d3d->default_bitmap->base;
+ texture.rowpixels = d3d->default_bitmap->rowpixels;
+ texture.width = d3d->default_bitmap->width;
+ texture.height = d3d->default_bitmap->height;
+ texture.palette = NULL;
+ texture.seqid = 0;
- if (primary_name)
- osd_free(primary_name);
- if (post_name)
- osd_free(post_name);
- if (prescale_name)
- osd_free(prescale_name);
- if (pincushion_name)
- osd_free(pincushion_name);
- if (phosphor_name)
- osd_free(phosphor_name);
- if (focus_name)
- osd_free(focus_name);
- if (deconverge_name)
- osd_free(deconverge_name);
- if (color_name)
- osd_free(color_name);
- if (yiq_encode_name)
- osd_free(yiq_encode_name);
- if (yiq_decode_name)
- osd_free(yiq_decode_name);
+ // now create it
+ d3d->default_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
}
+ int ret = d3d->hlsl->create_resources();
+ if (ret != 0)
+ return ret;
+
return device_create_resources(d3d);
}
@@ -1715,7 +817,7 @@ static int device_create_resources(d3d_info *d3d)
result = (*d3dintf->device.create_vertex_buffer)(d3d->device,
sizeof(d3d_vertex) * VERTEX_BUFFER_SIZE,
D3DUSAGE_DYNAMIC | D3DUSAGE_SOFTWAREPROCESSING | D3DUSAGE_WRITEONLY,
- VERTEX_BASE_FORMAT | ((d3d->hlsl_enable && d3dintf->post_fx_available) ? D3DFVF_XYZW : D3DFVF_XYZRHW), D3DPOOL_DEFAULT, &d3d->vertexbuf);
+ VERTEX_BASE_FORMAT | ((d3d->hlsl->enabled() && d3dintf->post_fx_available) ? D3DFVF_XYZW : D3DFVF_XYZRHW), D3DPOOL_DEFAULT, &d3d->vertexbuf);
if (result != D3D_OK)
{
mame_printf_error("Error creating vertex buffer (%08X)", (UINT32)result);
@@ -1723,7 +825,7 @@ static int device_create_resources(d3d_info *d3d)
}
// set the vertex format
- result = (*d3dintf->device.set_vertex_format)(d3d->device, (D3DFORMAT)(VERTEX_BASE_FORMAT | ((d3d->hlsl_enable && d3dintf->post_fx_available) ? D3DFVF_XYZW : D3DFVF_XYZRHW)));
+ result = (*d3dintf->device.set_vertex_format)(d3d->device, (D3DFORMAT)(VERTEX_BASE_FORMAT | ((d3d->hlsl->enabled() && d3dintf->post_fx_available) ? D3DFVF_XYZW : D3DFVF_XYZRHW)));
if (result != D3D_OK)
{
mame_printf_error("Error setting vertex format (%08X)", (UINT32)result);
@@ -1779,135 +881,6 @@ static int device_create_resources(d3d_info *d3d)
d3d->vector_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
}
- // experimental: create a default bitmap for our shader
- if (d3d->default_bitmap != NULL)
- {
- render_texinfo texture;
-
- // fake in the basic data so it looks like it came from render.c
- texture.base = d3d->default_bitmap->base;
- texture.rowpixels = d3d->default_bitmap->rowpixels;
- texture.width = d3d->default_bitmap->width;
- texture.height = d3d->default_bitmap->height;
- texture.palette = NULL;
- texture.seqid = 0;
-
- // now create it
- d3d->default_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
- }
-
- // experimental: initialize some more things if we're using HLSL
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
- {
- result = (*d3dintf->device.create_texture)(d3d->device, (int)(d3d->hlsl_snap_width), (int)(d3d->hlsl_snap_height), 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &d3d->hlsl_avi_copy_texture);
- if (result != D3D_OK)
- {
- mame_printf_verbose("Direct3D: Unable to init system-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
- return 1;
- }
- (*d3dintf->texture.get_surface_level)(d3d->hlsl_avi_copy_texture, 0, &d3d->hlsl_avi_copy_surface);
-
- result = (*d3dintf->device.create_texture)(d3d->device, (int)(d3d->hlsl_snap_width), (int)(d3d->hlsl_snap_height), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsl_avi_final_texture);
- if (result != D3D_OK)
- {
- mame_printf_verbose("Direct3D: Unable to init video-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
- return 1;
- }
- (*d3dintf->texture.get_surface_level)(d3d->hlsl_avi_final_texture, 0, &d3d->hlsl_avi_final_target);
-
- windows_options &options = downcast<windows_options &>(d3d->window->machine().options());
-
- // experimental: load a PNG to use for vector rendering; it is treated
- // as a brightness map
- emu_file file(d3d->window->machine().options().art_path(), OPEN_FLAG_READ);
- d3d->shadow_bitmap = render_load_png(file, NULL, options.screen_shadow_mask_texture(), NULL, NULL);
-
- // experimental: if we have a shadow bitmap, create a texture for it
- if (d3d->shadow_bitmap != NULL)
- {
- render_texinfo texture;
-
- // fake in the basic data so it looks like it came from render.c
- texture.base = d3d->shadow_bitmap->base;
- texture.rowpixels = d3d->shadow_bitmap->rowpixels;
- texture.width = d3d->shadow_bitmap->width;
- texture.height = d3d->shadow_bitmap->height;
- texture.palette = NULL;
- texture.seqid = 0;
-
- // now create it
- d3d->shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
- }
-
- d3d->hlsl_options = (d3d_options*)global_alloc_clear(d3d_options);
-
- if(d3d->hlsl_preset == -1)
- {
- d3d->hlsl_options->screen_shadow_mask_alpha = options.screen_shadow_mask_alpha();
- d3d->hlsl_options->screen_shadow_mask_count_x = options.screen_shadow_mask_count_x();
- d3d->hlsl_options->screen_shadow_mask_count_y = options.screen_shadow_mask_count_y();
- d3d->hlsl_options->screen_shadow_mask_u_size = options.screen_shadow_mask_u_size();
- d3d->hlsl_options->screen_shadow_mask_v_size = options.screen_shadow_mask_v_size();
- d3d->hlsl_options->screen_curvature = options.screen_curvature();
- d3d->hlsl_options->screen_pincushion = options.screen_pincushion();
- d3d->hlsl_options->screen_scanline_alpha = options.screen_scanline_amount();
- d3d->hlsl_options->screen_scanline_scale = options.screen_scanline_scale();
- d3d->hlsl_options->screen_scanline_height = options.screen_scanline_height();
- d3d->hlsl_options->screen_scanline_bright_scale = options.screen_scanline_bright_scale();
- d3d->hlsl_options->screen_scanline_bright_offset = options.screen_scanline_bright_offset();
- d3d->hlsl_options->screen_scanline_offset = options.screen_scanline_offset();
- d3d->hlsl_options->screen_defocus_x = options.screen_defocus_x();
- d3d->hlsl_options->screen_defocus_y = options.screen_defocus_y();
- d3d->hlsl_options->screen_red_converge_x = options.screen_red_converge_x();
- d3d->hlsl_options->screen_red_converge_y = options.screen_red_converge_y();
- d3d->hlsl_options->screen_green_converge_x = options.screen_green_converge_x();
- d3d->hlsl_options->screen_green_converge_y = options.screen_green_converge_y();
- d3d->hlsl_options->screen_blue_converge_x = options.screen_blue_converge_x();
- d3d->hlsl_options->screen_blue_converge_y = options.screen_blue_converge_y();
- d3d->hlsl_options->screen_red_radial_converge_x = options.screen_red_radial_converge_x();
- d3d->hlsl_options->screen_red_radial_converge_y = options.screen_red_radial_converge_y();
- d3d->hlsl_options->screen_green_radial_converge_x = options.screen_green_radial_converge_x();
- d3d->hlsl_options->screen_green_radial_converge_y = options.screen_green_radial_converge_y();
- d3d->hlsl_options->screen_blue_radial_converge_x = options.screen_blue_radial_converge_x();
- d3d->hlsl_options->screen_blue_radial_converge_y = options.screen_blue_radial_converge_y();
- d3d->hlsl_options->screen_red_from_red = options.screen_red_from_red();
- d3d->hlsl_options->screen_red_from_green = options.screen_red_from_green();
- d3d->hlsl_options->screen_red_from_blue = options.screen_red_from_blue();
- d3d->hlsl_options->screen_green_from_red = options.screen_green_from_red();
- d3d->hlsl_options->screen_green_from_green = options.screen_green_from_green();
- d3d->hlsl_options->screen_green_from_blue = options.screen_green_from_blue();
- d3d->hlsl_options->screen_blue_from_red = options.screen_blue_from_red();
- d3d->hlsl_options->screen_blue_from_green = options.screen_blue_from_green();
- d3d->hlsl_options->screen_blue_from_blue = options.screen_blue_from_blue();
- d3d->hlsl_options->screen_red_offset = options.screen_red_offset();
- d3d->hlsl_options->screen_green_offset = options.screen_green_offset();
- d3d->hlsl_options->screen_blue_offset = options.screen_blue_offset();
- d3d->hlsl_options->screen_red_scale = options.screen_red_scale();
- d3d->hlsl_options->screen_green_scale = options.screen_green_scale();
- d3d->hlsl_options->screen_blue_scale = options.screen_blue_scale();
- d3d->hlsl_options->screen_red_power = options.screen_red_power();
- d3d->hlsl_options->screen_green_power = options.screen_green_power();
- d3d->hlsl_options->screen_blue_power = options.screen_blue_power();
- d3d->hlsl_options->screen_red_floor = options.screen_red_floor();
- d3d->hlsl_options->screen_green_floor = options.screen_green_floor();
- d3d->hlsl_options->screen_blue_floor = options.screen_blue_floor();
- d3d->hlsl_options->screen_red_phosphor_life = options.screen_red_phosphor();
- d3d->hlsl_options->screen_green_phosphor_life = options.screen_green_phosphor();
- d3d->hlsl_options->screen_blue_phosphor_life = options.screen_blue_phosphor();
- d3d->hlsl_options->screen_saturation = options.screen_saturation();
- }
- else
- {
- d3d->hlsl_options = &g_d3d_hlsl_presets[d3d->hlsl_preset];
- }
-
- slider_list = init_slider_list(d3d);
- }
- else
- {
- d3d->hlsl_options = NULL;
- }
-
return 0;
}
@@ -1939,7 +912,7 @@ static void device_delete_resources(d3d_info *d3d)
// free all textures
while (d3d->texlist != NULL)
{
- texture_info *tex = d3d->texlist;
+ d3d_texture_info *tex = d3d->texlist;
d3d->texlist = tex->next;
if (tex->d3dfinaltex != NULL)
(*d3dintf->texture.release)(tex->d3dfinaltex);
@@ -1958,177 +931,7 @@ static void device_delete_resources(d3d_info *d3d)
global_free(d3d->default_texture);
// free our effects
- if(d3d->effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->effect);
- d3d->effect = NULL;
- }
- if(d3d->post_effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->post_effect);
- d3d->post_effect = NULL;
- }
- if(d3d->prescale_effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->prescale_effect);
- d3d->prescale_effect = NULL;
- }
- if(d3d->pincushion_effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->pincushion_effect);
- d3d->pincushion_effect = NULL;
- }
- if(d3d->phosphor_effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->phosphor_effect);
- d3d->phosphor_effect = NULL;
- }
- if(d3d->focus_effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->focus_effect);
- d3d->focus_effect = NULL;
- }
- if(d3d->deconverge_effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->deconverge_effect);
- d3d->deconverge_effect = NULL;
- }
- if(d3d->color_effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->color_effect);
- d3d->color_effect = NULL;
- }
- if(d3d->yiq_encode_effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->yiq_encode_effect);
- d3d->yiq_encode_effect = NULL;
- }
- if(d3d->yiq_decode_effect != NULL)
- {
- (*d3dintf->effect.release)(d3d->yiq_decode_effect);
- d3d->yiq_decode_effect = NULL;
- }
-
- for(int index = 0; index < 9; index++)
- {
- if (d3d->hlslprescaletexture0[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlslprescaletexture0[index]);
- d3d->hlslprescaletexture0[index] = NULL;
- }
- if (d3d->hlsltexture0[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture0[index]);
- d3d->hlsltexture0[index] = NULL;
- }
- if (d3d->hlsltexture1[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture1[index]);
- d3d->hlsltexture1[index] = NULL;
- }
- if (d3d->hlsltexture2[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture2[index]);
- d3d->hlsltexture2[index] = NULL;
- }
- if (d3d->hlsltexture3[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture3[index]);
- d3d->hlsltexture3[index] = NULL;
- }
- if (d3d->hlsltexture4[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture4[index]);
- d3d->hlsltexture4[index] = NULL;
- }
- if (d3d->hlslsmalltexture0[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlslsmalltexture0[index]);
- d3d->hlslsmalltexture0[index] = NULL;
- }
- if (d3d->hlslprescaletarget0[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlslprescaletarget0[index]);
- d3d->hlslprescaletarget0[index] = NULL;
- }
- if (d3d->hlsltarget0[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget0[index]);
- d3d->hlsltarget0[index] = NULL;
- }
- if (d3d->hlsltarget1[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget1[index]);
- d3d->hlsltarget1[index] = NULL;
- }
- if (d3d->hlsltarget2[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget2[index]);
- d3d->hlsltarget2[index] = NULL;
- }
- if (d3d->hlsltarget3[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget3[index]);
- d3d->hlsltarget3[index] = NULL;
- }
- if (d3d->hlsltarget4[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget4[index]);
- d3d->hlsltarget4[index] = NULL;
- }
- if (d3d->hlslsmalltarget0[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlslsmalltarget0[index]);
- d3d->hlslsmalltarget0[index] = NULL;
- }
- if(d3d->last_hlsltexture[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->last_hlsltexture[index]);
- d3d->last_hlsltexture[index] = NULL;
- }
- if(d3d->last_hlsltarget[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->last_hlsltarget[index]);
- d3d->last_hlsltarget[index] = NULL;
- }
- }
-
- if(d3d->hlsl_avi_copy_texture != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsl_avi_copy_texture);
- d3d->hlsl_avi_copy_texture = NULL;
- }
-
- if(d3d->hlsl_avi_copy_surface != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsl_avi_copy_surface);
- d3d->hlsl_avi_copy_surface = NULL;
- }
-
- if(d3d->hlsl_avi_final_texture != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsl_avi_final_texture);
- d3d->hlsl_avi_final_texture = NULL;
- }
-
- if(d3d->hlsl_avi_final_target != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsl_avi_final_target);
- d3d->hlsl_avi_final_target = NULL;
- }
-
- if(d3d->hlsl_options != NULL)
- {
- global_free(d3d->hlsl_options);
- }
-
- d3d->registered_targets = 0;
-
- if(d3d->shadow_texture != NULL)
- {
- global_free(d3d->shadow_texture);
- d3d->shadow_texture = NULL;
- }
+ d3d->hlsl->delete_resources();
}
@@ -2153,17 +956,15 @@ static int device_verify_caps(d3d_info *d3d, win_window_info *window)
result = (*d3dintf->d3d.get_caps_dword)(d3dintf, d3d->adapter, D3DDEVTYPE_HAL, CAPS_MAX_TEXTURE_HEIGHT, &d3d->texture_max_height);
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during get_caps_dword call\n", (int)result);
- d3d->hlsl_enable = downcast<windows_options &>(window->machine().options()).d3d_hlsl_enable() && d3dintf->post_fx_available;
- d3d->yiq_enable = downcast<windows_options &>(window->machine().options()).screen_yiq_enable();
- d3d->hlsl_prescale_size = 1;
- d3d->hlsl_preset = downcast<windows_options &>(window->machine().options()).d3d_hlsl_preset();
+ d3d->hlsl = global_alloc_clear(hlsl_info);
+ d3d->hlsl->init(d3dintf, window);
result = (*d3dintf->d3d.get_caps_dword)(d3dintf, d3d->adapter, D3DDEVTYPE_HAL, CAPS_MAX_PS30_INSN_SLOTS, &tempcaps);
if (result != D3D_OK) mame_printf_verbose("Direct3D Error %08X during get_caps_dword call\n", (int)result);
- if(tempcaps < 512 && d3d->hlsl_enable)
+ if(tempcaps < 512)
{
mame_printf_verbose("Direct3D: Warning - Device does not support Pixel Shader 3.0, falling back to non-PS rendering\n");
- d3d->hlsl_enable = false;
+ d3dintf->post_fx_available = false;
}
// verify presentation capabilities
@@ -2600,7 +1401,7 @@ static void draw_line(d3d_info *d3d, const render_primitive *prim)
render_bounds b0, b1;
d3d_vertex *vertex;
INT32 r, g, b, a;
- poly_info *poly;
+ d3d_poly_info *poly;
float effwidth;
DWORD color;
int i;
@@ -2705,11 +1506,11 @@ static void draw_line(d3d_info *d3d, const render_primitive *prim)
static void draw_quad(d3d_info *d3d, const render_primitive *prim)
{
- texture_info *texture = texture_find(d3d, prim);
+ d3d_texture_info *texture = texture_find(d3d, prim);
DWORD color, modmode;
d3d_vertex *vertex;
INT32 r, g, b, a;
- poly_info *poly;
+ d3d_poly_info *poly;
int i;
texture = texture != NULL ? texture : d3d->default_texture;
@@ -2791,52 +1592,6 @@ static void draw_quad(d3d_info *d3d, const render_primitive *prim)
}
-
-//============================================================
-// init_fsfx_quad
-//============================================================
-
-static void init_fsfx_quad(d3d_info *d3d)
-{
- // get a pointer to the vertex buffer
- d3d->fsfx_vertices = primitive_alloc(d3d, 4);
- if (d3d->fsfx_vertices == NULL)
- return;
-
- // fill in the vertexes clockwise
- windows_options &options = downcast<windows_options &>(d3d->window->machine().options());
- float scale_top = options.screen_scale_top();
- float scale_bottom = options.screen_scale_bottom();
-
- d3d->fsfx_vertices[0].x = (d3d->width * (scale_top * 0.5f - 0.5f));
- d3d->fsfx_vertices[0].y = 0.0f;
- d3d->fsfx_vertices[1].x = d3d->width - (d3d->width * (scale_top * 0.5f - 0.5f));
- d3d->fsfx_vertices[1].y = 0.0f;
- d3d->fsfx_vertices[2].x = (d3d->width * (scale_bottom * 0.5f - 0.5f));
- d3d->fsfx_vertices[2].y = d3d->height;
- d3d->fsfx_vertices[3].x = d3d->width - (d3d->width * (scale_bottom * 0.5f - 0.5f));
- d3d->fsfx_vertices[3].y = d3d->height;
-
- d3d->fsfx_vertices[0].u0 = 0.0f;
- d3d->fsfx_vertices[0].v0 = 0.0f;
- d3d->fsfx_vertices[1].u0 = 1.0f;
- d3d->fsfx_vertices[1].v0 = 0.0f;
- d3d->fsfx_vertices[2].u0 = 0.0f;
- d3d->fsfx_vertices[2].v0 = 1.0f;
- d3d->fsfx_vertices[3].u0 = 1.0f;
- d3d->fsfx_vertices[3].v0 = 1.0f;
-
- // set the color, Z parameters to standard values
- for (int i = 0; i < 4; i++)
- {
- d3d->fsfx_vertices[i].z = 0.0f;
- d3d->fsfx_vertices[i].rhw = 1.0f;
- d3d->fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);
- }
-}
-
-
-
//============================================================
// primitive_alloc
//============================================================
@@ -2892,29 +1647,11 @@ static void primitive_flush_pending(d3d_info *d3d)
result = (*d3dintf->device.set_stream_source)(d3d->device, 0, d3d->vertexbuf, sizeof(d3d_vertex));
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_stream_source call\n", (int)result);
- d3d_effect *curr_effect = d3d->effect;
-
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
- {
- (*d3dintf->effect.set_technique)(d3d->effect, "TestTechnique");
- (*d3dintf->effect.set_technique)(d3d->post_effect, "ScanMaskTechnique");
- (*d3dintf->effect.set_technique)(d3d->pincushion_effect, "TestTechnique");
- (*d3dintf->effect.set_technique)(d3d->phosphor_effect, "TestTechnique");
- (*d3dintf->effect.set_technique)(d3d->focus_effect, "TestTechnique");
- (*d3dintf->effect.set_technique)(d3d->deconverge_effect, "DeconvergeTechnique");
- (*d3dintf->effect.set_technique)(d3d->color_effect, "ColorTechnique");
- (*d3dintf->effect.set_technique)(d3d->yiq_encode_effect, "EncodeTechnique");
- (*d3dintf->effect.set_technique)(d3d->yiq_decode_effect, "DecodeTechnique");
- }
-
- d3d_surface *backbuffer = NULL;
- windows_options &winoptions = downcast<windows_options &>(d3d->window->machine().options());
+ d3d->hlsl->begin();
// first remember the original render target in case we need to set a new one
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
+ if(d3d->hlsl->enabled() && d3dintf->post_fx_available)
{
- result = (*d3dintf->device.get_render_target)(d3d->device, 0, &backbuffer);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result);
vertnum = 4;
}
else
@@ -2922,14 +1659,10 @@ static void primitive_flush_pending(d3d_info *d3d)
vertnum = 0;
}
- bool screen_encountered[9] = { false };
-
- d3d_options *options = d3d->hlsl_options;
-
// now do the polys
for (polynum = 0; polynum < d3d->numpolys; polynum++)
{
- poly_info *poly = &d3d->poly[polynum];
+ d3d_poly_info *poly = &d3d->poly[polynum];
int newfilter;
// set the texture if different
@@ -2938,9 +1671,6 @@ static void primitive_flush_pending(d3d_info *d3d)
// set filtering if different
if (poly->texture != NULL)
{
- screen_encountered[poly->texture->target_index] = true;
- d3d->target_in_use[poly->texture->target_index] = poly->texture;
-
newfilter = FALSE;
if (PRIMFLAG_GET_SCREENTEX(poly->flags))
newfilter = video_config.filter;
@@ -2948,510 +1678,17 @@ static void primitive_flush_pending(d3d_info *d3d)
set_wrap(d3d, PRIMFLAG_GET_TEXWRAP(poly->flags));
set_modmode(d3d, poly->modmode);
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
- {
- if(PRIMFLAG_GET_TEXSHADE(d3d->last_texture_flags))
- {
- curr_effect = d3d->pincushion_effect;
- }
- else if(PRIMFLAG_GET_SCREENTEX(d3d->last_texture_flags) && poly->texture != NULL)
- {
- // Plug in all of the shader settings we're going to need
- // This is extremely slow, but we're not rendering models here,
- // just post-processing.
- curr_effect = d3d->post_effect;
-
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart));
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart));
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "Prescale", (float)d3d->hlsl_prescale_size);
- (*d3dintf->effect.set_float)(curr_effect, "RedFloor", options->screen_red_floor);
- (*d3dintf->effect.set_float)(curr_effect, "GrnFloor", options->screen_green_floor);
- (*d3dintf->effect.set_float)(curr_effect, "BluFloor", options->screen_blue_floor);
- (*d3dintf->effect.set_float)(curr_effect, "SnapX", d3d->hlsl_snap_width);
- (*d3dintf->effect.set_float)(curr_effect, "SnapY", d3d->hlsl_snap_height);
- (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->screen_pincushion);
- (*d3dintf->effect.set_float)(curr_effect, "CurvatureAmount", options->screen_curvature);
- (*d3dintf->effect.set_float)(curr_effect, "UseShadow", d3d->shadow_texture == NULL ? 0.0f : 1.0f);
- (*d3dintf->effect.set_texture)(curr_effect, "Shadow", d3d->shadow_texture == NULL ? NULL : d3d->shadow_texture->d3dfinaltex);
- (*d3dintf->effect.set_float)(curr_effect, "ShadowBrightness", options->screen_shadow_mask_alpha);
- (*d3dintf->effect.set_float)(curr_effect, "ShadowMaskSizeX", (float)options->screen_shadow_mask_count_x);
- (*d3dintf->effect.set_float)(curr_effect, "ShadowMaskSizeY", (float)options->screen_shadow_mask_count_y);
- (*d3dintf->effect.set_float)(curr_effect, "ShadowU", options->screen_shadow_mask_u_size);
- (*d3dintf->effect.set_float)(curr_effect, "ShadowV", options->screen_shadow_mask_v_size);
- (*d3dintf->effect.set_float)(curr_effect, "ShadowWidth", d3d->shadow_texture == NULL ? 1.0f : (float)d3d->shadow_texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "ShadowHeight", d3d->shadow_texture == NULL ? 1.0f : (float)d3d->shadow_texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "ScanlineAmount", options->screen_scanline_alpha);
- (*d3dintf->effect.set_float)(curr_effect, "ScanlineScale", options->screen_scanline_scale);
- (*d3dintf->effect.set_float)(curr_effect, "ScanlineHeight", options->screen_scanline_height);
- (*d3dintf->effect.set_float)(curr_effect, "ScanlineBrightScale", options->screen_scanline_bright_scale);
- (*d3dintf->effect.set_float)(curr_effect, "ScanlineBrightOffset", options->screen_scanline_bright_offset);
- (*d3dintf->effect.set_float)(curr_effect, "ScanlineOffset", (poly->texture->cur_frame == 0) ? 0.0f : options->screen_scanline_offset);
- }
- else
- {
- curr_effect = d3d->effect;
-
- (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f);
- }
- }
+ d3d->hlsl->init_effect_info(poly);
}
// set the blendmode if different
set_blendmode(d3d, PRIMFLAG_GET_BLENDMODE(poly->flags));
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
+ if(d3d->hlsl->enabled() && d3dintf->post_fx_available)
{
assert(vertnum + poly->numverts <= d3d->numverts);
- UINT num_passes = 0;
-
- if(PRIMFLAG_GET_SCREENTEX(d3d->last_texture_flags) && poly->texture != NULL)
- {
- d3d->target_use_count[poly->texture->target_index] = 60;
-
- if(d3d->yiq_enable)
- {
- /* Convert our signal into YIQ */
- curr_effect = d3d->yiq_encode_effect;
-
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart));
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart));
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "CCValue", winoptions.screen_yiq_cc());
- (*d3dintf->effect.set_float)(curr_effect, "AValue", winoptions.screen_yiq_a());
- (*d3dintf->effect.set_float)(curr_effect, "BValue", (poly->texture->cur_frame == 2) ? 0.0f : ((float)poly->texture->cur_frame * winoptions.screen_yiq_b()));
- (*d3dintf->effect.set_float)(curr_effect, "PValue", winoptions.screen_yiq_p());
- (*d3dintf->effect.set_float)(curr_effect, "YFreqResponse", winoptions.screen_yiq_y());
- (*d3dintf->effect.set_float)(curr_effect, "IFreqResponse", winoptions.screen_yiq_i());
- (*d3dintf->effect.set_float)(curr_effect, "QFreqResponse", winoptions.screen_yiq_q());
- (*d3dintf->effect.set_float)(curr_effect, "ScanTime", winoptions.screen_yiq_scan_time());
- (*d3dintf->effect.set_float)(curr_effect, "Prescale", (float)d3d->hlsl_prescale_size);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsltarget4[poly->texture->target_index]);
-
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
- result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, 0, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
- /* Convert our signal from YIQ */
- curr_effect = d3d->yiq_decode_effect;
-
- (*d3dintf->effect.set_texture)(curr_effect, "Composite", d3d->hlsltexture4[poly->texture->target_index]);
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dfinaltex);
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart));
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart));
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "CCValue", winoptions.screen_yiq_cc());
- (*d3dintf->effect.set_float)(curr_effect, "AValue", winoptions.screen_yiq_a());
- (*d3dintf->effect.set_float)(curr_effect, "BValue", (poly->texture->cur_frame == 2) ? 0.0f : ((float)poly->texture->cur_frame * winoptions.screen_yiq_b()));
- (*d3dintf->effect.set_float)(curr_effect, "OValue", winoptions.screen_yiq_o());
- (*d3dintf->effect.set_float)(curr_effect, "PValue", winoptions.screen_yiq_p());
- (*d3dintf->effect.set_float)(curr_effect, "YFreqResponse", winoptions.screen_yiq_y());
- (*d3dintf->effect.set_float)(curr_effect, "IFreqResponse", winoptions.screen_yiq_i());
- (*d3dintf->effect.set_float)(curr_effect, "QFreqResponse", winoptions.screen_yiq_q());
- (*d3dintf->effect.set_float)(curr_effect, "ScanTime", winoptions.screen_yiq_scan_time());
- (*d3dintf->effect.set_float)(curr_effect, "Prescale", (float)d3d->hlsl_prescale_size);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsltarget3[poly->texture->target_index]);
-
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
- result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, 0, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
- curr_effect = d3d->color_effect;
-
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", d3d->hlsltexture3[poly->texture->target_index]);
- }
-
- curr_effect = d3d->color_effect;
-
- /* Render the initial color-convolution pass */
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", d3d->yiq_enable ? 1.0f : (1.0f / (poly->texture->ustop - poly->texture->ustart)));
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", d3d->yiq_enable ? 1.0f : (1.0f / (poly->texture->vstop - poly->texture->vstart)));
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "YIQEnable", d3d->yiq_enable ? 1.0f : 0.0f);
- (*d3dintf->effect.set_float)(curr_effect, "RedFromRed", options->screen_red_from_red);
- (*d3dintf->effect.set_float)(curr_effect, "RedFromGrn", options->screen_red_from_green);
- (*d3dintf->effect.set_float)(curr_effect, "RedFromBlu", options->screen_red_from_blue);
- (*d3dintf->effect.set_float)(curr_effect, "GrnFromRed", options->screen_green_from_red);
- (*d3dintf->effect.set_float)(curr_effect, "GrnFromGrn", options->screen_green_from_green);
- (*d3dintf->effect.set_float)(curr_effect, "GrnFromBlu", options->screen_green_from_blue);
- (*d3dintf->effect.set_float)(curr_effect, "BluFromRed", options->screen_blue_from_red);
- (*d3dintf->effect.set_float)(curr_effect, "BluFromGrn", options->screen_blue_from_green);
- (*d3dintf->effect.set_float)(curr_effect, "BluFromBlu", options->screen_blue_from_blue);
- (*d3dintf->effect.set_float)(curr_effect, "RedOffset", options->screen_red_offset);
- (*d3dintf->effect.set_float)(curr_effect, "GrnOffset", options->screen_green_offset);
- (*d3dintf->effect.set_float)(curr_effect, "BluOffset", options->screen_blue_offset);
- (*d3dintf->effect.set_float)(curr_effect, "RedScale", options->screen_red_scale);
- (*d3dintf->effect.set_float)(curr_effect, "GrnScale", options->screen_green_scale);
- (*d3dintf->effect.set_float)(curr_effect, "BluScale", options->screen_blue_scale);
- (*d3dintf->effect.set_float)(curr_effect, "RedPower", options->screen_red_power);
- (*d3dintf->effect.set_float)(curr_effect, "GrnPower", options->screen_green_power);
- (*d3dintf->effect.set_float)(curr_effect, "BluPower", options->screen_blue_power);
- (*d3dintf->effect.set_float)(curr_effect, "Saturation", options->screen_saturation);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlslsmalltarget0[poly->texture->target_index]);
-
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
- result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, 0, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
- /* Pre-scaling pass */
- curr_effect = d3d->prescale_effect;
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", d3d->hlslsmalltexture0[poly->texture->target_index]);
-
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart));
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart));
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlslprescaletarget0[poly->texture->target_index]);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
- result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, 0, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
-
- /* Deconverge pass */
- curr_effect = d3d->deconverge_effect;
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", d3d->hlslprescaletexture0[poly->texture->target_index]);
-
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart));
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart));
- (*d3dintf->effect.set_float)(curr_effect, "Prescale", d3d->hlsl_prescale_size);
- (*d3dintf->effect.set_float)(curr_effect, "RedConvergeX", options->screen_red_converge_x);
- (*d3dintf->effect.set_float)(curr_effect, "RedConvergeY", options->screen_red_converge_y);
- (*d3dintf->effect.set_float)(curr_effect, "GrnConvergeX", options->screen_green_converge_x);
- (*d3dintf->effect.set_float)(curr_effect, "GrnConvergeY", options->screen_green_converge_y);
- (*d3dintf->effect.set_float)(curr_effect, "BluConvergeX", options->screen_blue_converge_x);
- (*d3dintf->effect.set_float)(curr_effect, "BluConvergeY", options->screen_blue_converge_y);
- (*d3dintf->effect.set_float)(curr_effect, "RedRadialConvergeX", options->screen_red_radial_converge_x);
- (*d3dintf->effect.set_float)(curr_effect, "RedRadialConvergeY", options->screen_red_radial_converge_y);
- (*d3dintf->effect.set_float)(curr_effect, "GrnRadialConvergeX", options->screen_green_radial_converge_x);
- (*d3dintf->effect.set_float)(curr_effect, "GrnRadialConvergeY", options->screen_green_radial_converge_y);
- (*d3dintf->effect.set_float)(curr_effect, "BluRadialConvergeX", options->screen_blue_radial_converge_x);
- (*d3dintf->effect.set_float)(curr_effect, "BluRadialConvergeY", options->screen_blue_radial_converge_y);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsltarget2[poly->texture->target_index]);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result);
- result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, 0, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
- float defocus_x = options->screen_defocus_x;
- float defocus_y = options->screen_defocus_y;
- bool focus_enable = defocus_x != 0.0f || defocus_y != 0.0f;
- if(focus_enable)
- {
- /* Defocus pass 1 */
- curr_effect = d3d->focus_effect;
-
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", d3d->hlsltexture2[poly->texture->target_index]);
-
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
- (*d3dintf->effect.set_float)(curr_effect, "DefocusX", defocus_x);
- (*d3dintf->effect.set_float)(curr_effect, "DefocusY", defocus_y);
- (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsltarget0[poly->texture->target_index]);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result);
- result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, 0, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
- /* Defocus pass 2 */
-
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", d3d->hlsltexture0[poly->texture->target_index]);
-
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f);
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f);
- (*d3dintf->effect.set_float)(curr_effect, "DefocusX", defocus_x);
- (*d3dintf->effect.set_float)(curr_effect, "DefocusY", defocus_y);
- (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsltarget1[poly->texture->target_index]);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 7\n", (int)result);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, 0, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
- }
-
- // Simulate phosphorescence. This should happen after the shadow/scanline pass, but since
- // the phosphors are a direct result of the incoming texture, might as well just change the
- // input texture.
- curr_effect = d3d->phosphor_effect;
-
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "RedPhosphor", options->screen_red_phosphor_life);
- (*d3dintf->effect.set_float)(curr_effect, "GreenPhosphor", options->screen_green_phosphor_life);
- (*d3dintf->effect.set_float)(curr_effect, "BluePhosphor", options->screen_blue_phosphor_life);
-
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", focus_enable ? d3d->hlsltexture1[poly->texture->target_index] : d3d->hlsltexture2[poly->texture->target_index]);
- (*d3dintf->effect.set_texture)(curr_effect, "LastPass", d3d->last_hlsltexture[poly->texture->target_index]);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsltarget0[poly->texture->target_index]);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 4\n", (int)result);
- result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, 0, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
- /* Pass along our phosphor'd screen */
- curr_effect = d3d->phosphor_effect;
-
- (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f);
-
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", focus_enable ? d3d->hlsltexture1[poly->texture->target_index] : d3d->hlsltexture2[poly->texture->target_index]);
- (*d3dintf->effect.set_texture)(curr_effect, "LastPass", focus_enable ? d3d->hlsltexture1[poly->texture->target_index] : d3d->hlsltexture2[poly->texture->target_index]);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->last_hlsltarget[poly->texture->target_index]);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 5\n", (int)result);
- result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, 0, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
- /* Scanlines and shadow mask, at high res for AVI logging*/
- if(d3d->hlsl_avi_file != NULL)
- {
- curr_effect = d3d->post_effect;
-
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", d3d->hlsltexture0[poly->texture->target_index]);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsl_avi_final_target);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
- }
-
- if(d3d->hlsl_render_snap)
- {
- curr_effect = d3d->post_effect;
-
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", d3d->hlsltexture0[poly->texture->target_index]);
-
- (*d3dintf->effect.set_float)(curr_effect, "SnapX", d3d->hlsl_snap_width);
- (*d3dintf->effect.set_float)(curr_effect, "SnapY", d3d->hlsl_snap_height);
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsl_snap_target);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
- d3d->hlsl_snap_rendered = true;
- }
-
- (*d3dintf->effect.set_float)(curr_effect, "SnapX", d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "SnapY", d3d->height);
-
- /* Scanlines and shadow mask */
- curr_effect = d3d->post_effect;
-
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", d3d->hlsltexture0[poly->texture->target_index]);
-
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
-
- poly->texture->cur_frame++;
- poly->texture->cur_frame %= winoptions.screen_yiq_phase_count();
- }
- else
- {
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "PostPass", 0.0f);
- (*d3dintf->effect.set_float)(curr_effect, "PincushionAmountX", options->screen_pincushion);
- (*d3dintf->effect.set_float)(curr_effect, "PincushionAmountY", options->screen_pincushion);
-
- (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
-
- for (UINT pass = 0; pass < num_passes; pass++)
- {
- (*d3dintf->effect.begin_pass)(curr_effect, pass);
- // add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
- (*d3dintf->effect.end_pass)(curr_effect);
- }
-
- (*d3dintf->effect.end)(curr_effect);
- }
+ d3d->hlsl->render_quad(poly, vertnum);
}
else
{
@@ -3465,140 +1702,7 @@ static void primitive_flush_pending(d3d_info *d3d)
vertnum += poly->numverts;
}
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
- {
- (*d3dintf->surface.release)(backbuffer);
- }
-
- // Unregister any registered targets we didn't traverse in the past frame. A resolution change must
- // have occurred.
- for(int index = 0; index < 9 && d3d->hlsl_enable && d3dintf->post_fx_available; index++)
- {
- if(!screen_encountered[index] && d3d->hlslsmalltarget0[index] != NULL)
- {
- if(d3d->target_use_count[index] > 0)
- {
- d3d->target_use_count[index]--;
- }
- else
- {
- // free all textures
- if(d3d->target_in_use[index] != NULL)
- {
- texture_info *tex = d3d->target_in_use[index];
- if(d3d->texlist == tex)
- {
- d3d->texlist = tex->next;
- if(d3d->texlist != NULL)
- {
- d3d->texlist->prev = NULL;
- }
- }
- else
- {
- if(tex->next != NULL)
- {
- tex->next->prev = tex->prev;
- }
- if(tex->prev != NULL)
- {
- tex->prev->next = tex->next;
- }
- }
-
- if (tex->d3dfinaltex != NULL)
- (*d3dintf->texture.release)(tex->d3dfinaltex);
- if (tex->d3dtex != NULL && tex->d3dtex != tex->d3dfinaltex)
- (*d3dintf->texture.release)(tex->d3dtex);
- if (tex->d3dsurface != NULL)
- (*d3dintf->surface.release)(tex->d3dsurface);
- global_free(tex);
- }
-
- if (d3d->hlslprescaletexture0[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlslprescaletexture0[index]);
- d3d->hlslprescaletexture0[index] = NULL;
- }
- if (d3d->hlsltexture0[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture0[index]);
- d3d->hlsltexture0[index] = NULL;
- }
- if (d3d->hlsltexture1[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture1[index]);
- d3d->hlsltexture1[index] = NULL;
- }
- if (d3d->hlsltexture2[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture2[index]);
- d3d->hlsltexture2[index] = NULL;
- }
- if (d3d->hlsltexture3[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture3[index]);
- d3d->hlsltexture3[index] = NULL;
- }
- if (d3d->hlsltexture4[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsltexture4[index]);
- d3d->hlsltexture4[index] = NULL;
- }
- if (d3d->hlslsmalltexture0[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlslsmalltexture0[index]);
- d3d->hlslsmalltexture0[index] = NULL;
- }
- if (d3d->hlslprescaletarget0[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlslprescaletarget0[index]);
- d3d->hlslprescaletarget0[index] = NULL;
- }
- if (d3d->hlsltarget0[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget0[index]);
- d3d->hlsltarget0[index] = NULL;
- }
- if (d3d->hlsltarget1[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget1[index]);
- d3d->hlsltarget1[index] = NULL;
- }
- if (d3d->hlsltarget2[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget2[index]);
- d3d->hlsltarget2[index] = NULL;
- }
- if (d3d->hlsltarget3[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget3[index]);
- d3d->hlsltarget3[index] = NULL;
- }
- if (d3d->hlsltarget4[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsltarget4[index]);
- d3d->hlsltarget4[index] = NULL;
- }
- if (d3d->hlslsmalltarget0[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlslsmalltarget0[index]);
- d3d->hlslsmalltarget0[index] = NULL;
- }
- if(d3d->last_hlsltexture[index] != NULL)
- {
- (*d3dintf->texture.release)(d3d->last_hlsltexture[index]);
- d3d->last_hlsltexture[index] = NULL;
- }
- if(d3d->last_hlsltarget[index] != NULL)
- {
- (*d3dintf->surface.release)(d3d->last_hlsltarget[index]);
- d3d->last_hlsltarget[index] = NULL;
- }
- d3d->target_use_count[index] = 0;
- }
- }
- }
+ d3d->hlsl->end();
// reset the vertex count
d3d->numverts = 0;
@@ -3607,303 +1711,16 @@ static void primitive_flush_pending(d3d_info *d3d)
//============================================================
-// hlsl_avi_update_snap
-//============================================================
-
-static void hlsl_avi_update_snap(d3d_info *d3d, d3d_surface *surface)
-{
- D3DLOCKED_RECT rect;
-
- // if we don't have a bitmap, or if it's not the right size, allocate a new one
- if (d3d->hlsl_avi_snap == NULL || (int)(d3d->hlsl_snap_width) != d3d->hlsl_avi_snap->width || (int)(d3d->hlsl_snap_height) != d3d->hlsl_avi_snap->height)
- {
- if (d3d->hlsl_avi_snap != NULL)
- {
- auto_free(d3d->window->machine(), d3d->hlsl_avi_snap);
- }
- d3d->hlsl_avi_snap = auto_alloc(d3d->window->machine(), bitmap_t((int)(d3d->hlsl_snap_width), (int)(d3d->hlsl_snap_height), BITMAP_FORMAT_RGB32));
- }
-
- // copy the texture
- HRESULT result = (*d3dintf->device.get_render_target_data)(d3d->device, surface, d3d->hlsl_avi_copy_surface);
- if (result != D3D_OK)
- {
- printf("Couldn't copy (%08x)\n", (UINT32)result);
- return;
- }
-
- // lock the texture
- result = (*d3dintf->surface.lock_rect)(d3d->hlsl_avi_copy_surface, &rect, NULL, D3DLOCK_DISCARD);
- if (result != D3D_OK)
- {
- printf("Couldn't lock (%08x)\n", (UINT32)result);
- return;
- }
-
- // loop over Y
- for (int srcy = 0; srcy < (int)d3d->hlsl_snap_height; srcy++)
- {
- BYTE *src = (BYTE *)rect.pBits + srcy * rect.Pitch;
- BYTE *dst = (BYTE *)d3d->hlsl_avi_snap->base + srcy * d3d->hlsl_avi_snap->rowpixels * 4;
-
- for(int x = 0; x < d3d->hlsl_snap_width; x++)
- {
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = *src++;
- }
- }
-
- // unlock
- result = (*d3dintf->surface.unlock_rect)(d3d->hlsl_avi_copy_surface);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during texture unlock_rect call\n", (int)result);
-}
-
-
-
-//============================================================
-// hlsl_render_snapshot
-//============================================================
-
-static void hlsl_render_snapshot(d3d_info *d3d, d3d_surface *surface)
-{
- D3DLOCKED_RECT rect;
-
- d3d->hlsl_render_snap = false;
-
- // if we don't have a bitmap, or if it's not the right size, allocate a new one
- if (d3d->hlsl_avi_snap == NULL || d3d->hlsl_snap_width != (d3d->hlsl_avi_snap->width / 2) || d3d->hlsl_snap_height != (d3d->hlsl_avi_snap->height / 2))
- {
- if (d3d->hlsl_avi_snap != NULL)
- {
- auto_free(d3d->window->machine(), d3d->hlsl_avi_snap);
- }
- d3d->hlsl_avi_snap = auto_alloc(d3d->window->machine(), bitmap_t(d3d->hlsl_snap_width / 2, d3d->hlsl_snap_height / 2, BITMAP_FORMAT_RGB32));
- }
-
- // copy the texture
- HRESULT result = (*d3dintf->device.get_render_target_data)(d3d->device, surface, d3d->hlsl_snap_copy_target);
- if (result != D3D_OK)
- {
- printf("Couldn't copy (%08x)\n", (UINT32)result);
- return;
- }
-
- // lock the texture
- result = (*d3dintf->surface.lock_rect)(d3d->hlsl_snap_copy_target, &rect, NULL, D3DLOCK_DISCARD);
- if (result != D3D_OK)
- {
- printf("Couldn't lock (%08x)\n", (UINT32)result);
- return;
- }
-
- for(int cy = 0; cy < 2; cy++)
- {
- for(int cx = 0; cx < 2; cx++)
- {
- // loop over Y
- for (int srcy = 0; srcy < d3d->hlsl_snap_height / 2; srcy++)
- {
- int toty = (srcy + cy * (d3d->hlsl_snap_height / 2));
- int totx = cx * (d3d->hlsl_snap_width / 2);
- BYTE *src = (BYTE *)rect.pBits + toty * rect.Pitch + totx * 4;
- BYTE *dst = (BYTE *)d3d->hlsl_avi_snap->base + srcy * d3d->hlsl_avi_snap->rowpixels * 4;
-
- for(int x = 0; x < d3d->hlsl_snap_width / 2; x++)
- {
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = *src++;
- }
- }
-
- int idx = cy * 2 + cx;
-
- emu_file file(d3d->window->machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- file_error filerr = open_next(d3d, file, "png", idx);
- if (filerr != FILERR_NONE)
- return;
-
- // add two text entries describing the image
- astring text1(APPNAME, " ", build_version);
- astring text2(d3d->window->machine().system().manufacturer, " ", d3d->window->machine().system().description);
- png_info pnginfo = { 0 };
- png_add_text(&pnginfo, "Software", text1);
- png_add_text(&pnginfo, "System", text2);
-
- // now do the actual work
- png_error error = png_write_bitmap(file, &pnginfo, d3d->hlsl_avi_snap, 1 << 24, NULL);
- if (error != PNGERR_NONE)
- mame_printf_error("Error generating PNG for HLSL snapshot: png_error = %d\n", error);
-
- // free any data allocated
- png_free(&pnginfo);
- }
- }
-
- // unlock
- result = (*d3dintf->surface.unlock_rect)(d3d->hlsl_snap_copy_target);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during texture unlock_rect call\n", (int)result);
-
- if(d3d->hlsl_snap_texture != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsl_snap_texture);
- d3d->hlsl_snap_texture = NULL;
- }
-
- if(d3d->hlsl_snap_target != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsl_snap_target);
- d3d->hlsl_snap_target = NULL;
- }
-
- if(d3d->hlsl_snap_copy_texture != NULL)
- {
- (*d3dintf->texture.release)(d3d->hlsl_snap_copy_texture);
- d3d->hlsl_snap_copy_texture = NULL;
- }
-
- if(d3d->hlsl_snap_copy_target != NULL)
- {
- (*d3dintf->surface.release)(d3d->hlsl_snap_copy_target);
- d3d->hlsl_snap_copy_target = NULL;
- }
-}
-
-
-//============================================================
-// hlsl_record_texture
-//============================================================
-
-static void hlsl_record_texture(d3d_info *d3d, d3d_surface *surface)
-{
- // ignore if nothing to do
- if (d3d->hlsl_avi_file == NULL || surface == NULL)
- {
- return;
- }
-
- // get the current time
- attotime curtime = d3d->window->machine().time();
-
- hlsl_avi_update_snap(d3d, surface);
-
- // loop until we hit the right time
- while (d3d->hlsl_avi_next_frame_time <= curtime)
- {
- // handle an AVI recording
- // write the next frame
- avi_error avierr = avi_append_video_frame_rgb32(d3d->hlsl_avi_file, d3d->hlsl_avi_snap);
- if (avierr != AVIERR_NONE)
- {
- end_hlsl_avi_recording(d3d);
- return;
- }
-
- // advance time
- d3d->hlsl_avi_next_frame_time += d3d->hlsl_avi_frame_period;
- d3d->hlsl_avi_frame++;
- }
-}
-
-
-//============================================================
-// end_hlsl_avi_recording
-//============================================================
-
-static void end_hlsl_avi_recording(d3d_info *d3d)
-{
- if(d3d->hlsl_avi_file != NULL)
- {
- avi_close(d3d->hlsl_avi_file);
- }
- d3d->hlsl_avi_file = NULL;
- d3d->hlsl_avi_frame = 0;
-}
-
-
-//============================================================
-// begin_hlsl_avi_recording
-//============================================================
-
-static void begin_hlsl_avi_recording(d3d_info *d3d, const char *name)
-{
- // stop any existing recording
- end_hlsl_avi_recording(d3d);
-
- // reset the state
- d3d->hlsl_avi_frame = 0;
- d3d->hlsl_avi_next_frame_time = d3d->window->machine().time();
-
- // build up information about this new movie
- avi_movie_info info;
- info.video_format = 0;
- info.video_timescale = 1000 * ((d3d->window->machine().primary_screen != NULL) ? ATTOSECONDS_TO_HZ(d3d->window->machine().primary_screen->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE);
- info.video_sampletime = 1000;
- info.video_numsamples = 0;
- info.video_width = d3d->hlsl_snap_width;
- info.video_height = d3d->hlsl_snap_height;
- info.video_depth = 24;
-
- info.audio_format = 0;
- info.audio_timescale = d3d->window->machine().sample_rate();
- info.audio_sampletime = 1;
- info.audio_numsamples = 0;
- info.audio_channels = 2;
- info.audio_samplebits = 16;
- info.audio_samplerate = d3d->window->machine().sample_rate();
-
- // create a new temporary movie file
- file_error filerr;
- astring fullpath;
- {
- emu_file tempfile(d3d->window->machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (name != NULL)
- {
- filerr = tempfile.open(name);
- }
- else
- {
- filerr = open_next(d3d, tempfile, "avi", 0);
- }
-
- // compute the frame time
- {
- d3d->hlsl_avi_frame_period = attotime::from_seconds(1000) / info.video_timescale;
- }
-
- // if we succeeded, make a copy of the name and create the real file over top
- if (filerr == FILERR_NONE)
- {
- fullpath = tempfile.fullpath();
- }
- }
-
- if (filerr == FILERR_NONE)
- {
- // create the file and free the string
- avi_error avierr = avi_create(fullpath, &info, &d3d->hlsl_avi_file);
- if (avierr != AVIERR_NONE)
- {
- mame_printf_error("Error creating AVI: %s\n", avi_error_string(avierr));
- }
- }
-}
-
-
-//============================================================
// texture_create
//============================================================
-static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsource, UINT32 flags)
+d3d_texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsource, UINT32 flags)
{
- texture_info *texture;
+ d3d_texture_info *texture;
HRESULT result;
// allocate a new texture
- texture = global_alloc_clear(texture_info);
+ texture = global_alloc_clear(d3d_texture_info);
// fill in the core data
texture->hash = texture_compute_hash(texsource, flags);
@@ -3971,61 +1788,9 @@ static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsour
texture->d3dfinaltex = texture->d3dtex;
texture->type = d3d->dynamic_supported ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN;
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
- {
- int idx = d3d->registered_targets;
-
- // Find the nearest prescale factor that is over our screen size
- int hlsl_prescale = 1;
- while(texture->rawwidth * hlsl_prescale < d3d->width) hlsl_prescale++;
- d3d->hlsl_prescale_size = hlsl_prescale;
-
- result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture0[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture0[idx], 0, &d3d->hlsltarget0[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture1[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture1[idx], 0, &d3d->hlsltarget1[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture2[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture2[idx], 0, &d3d->hlsltarget2[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture3[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture3[idx], 0, &d3d->hlsltarget3[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture4[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture4[idx], 0, &d3d->hlsltarget4[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlslsmalltexture0[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlslsmalltexture0[idx], 0, &d3d->hlslsmalltarget0[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlslprescaletexture0[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlslprescaletexture0[idx], 0, &d3d->hlslprescaletarget0[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, d3d->width, d3d->height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->last_hlsltexture[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->last_hlsltexture[idx], 0, &d3d->last_hlsltarget[idx]);
-
- texture->target_index = d3d->registered_targets;
- d3d->target_use_count[texture->target_index] = 60;
- d3d->target_in_use[texture->target_index] = texture;
- d3d->registered_targets++;
- d3d->registered_targets %= 9;
- }
+ int ret = d3d->hlsl->register_texture(texture);
+ if (ret != 0)
+ goto error;
break;
}
@@ -4065,61 +1830,10 @@ static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsour
result = (*d3dintf->device.create_texture)(d3d->device, scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, finalfmt, D3DPOOL_DEFAULT, &texture->d3dfinaltex);
if (result == D3D_OK)
{
- if(d3d->hlsl_enable && d3dintf->post_fx_available)
- {
- int idx = d3d->registered_targets;
-
- // Find the nearest prescale factor that is over our screen size
- int hlsl_prescale = 1;
- while(scwidth * hlsl_prescale < d3d->width) hlsl_prescale++;
- d3d->hlsl_prescale_size = hlsl_prescale;
-
- result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture0[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture0[idx], 0, &d3d->hlsltarget0[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture1[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture1[idx], 0, &d3d->hlsltarget1[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture2[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture2[idx], 0, &d3d->hlsltarget2[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture3[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture3[idx], 0, &d3d->hlsltarget3[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture4[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlsltexture4[idx], 0, &d3d->hlsltarget4[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlslsmalltexture0[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlslsmalltexture0[idx], 0, &d3d->hlslsmalltarget0[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlslprescaletexture0[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->hlslprescaletexture0[idx], 0, &d3d->hlslprescaletarget0[idx]);
-
- result = (*d3dintf->device.create_texture)(d3d->device, d3d->width, d3d->height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->last_hlsltexture[idx]);
- if (result != D3D_OK)
- goto error;
- (*d3dintf->texture.get_surface_level)(d3d->last_hlsltexture[idx], 0, &d3d->last_hlsltarget[idx]);
-
- texture->target_index = d3d->registered_targets;
- d3d->target_use_count[texture->target_index] = 60;
- d3d->target_in_use[texture->target_index] = texture;
- d3d->registered_targets++;
- d3d->registered_targets %= 9;
- }
+ int ret = d3d->hlsl->register_prescaled_texture(texture, scwidth, scheight);
+ if (ret != 0)
+ goto error;
+
break;
}
(*d3dintf->texture.release)(texture->d3dtex);
@@ -4156,7 +1870,7 @@ error:
// texture_compute_size
//============================================================
-static void texture_compute_size(d3d_info *d3d, int texwidth, int texheight, texture_info *texture)
+static void texture_compute_size(d3d_info *d3d, int texwidth, int texheight, d3d_texture_info *texture)
{
int finalheight = texheight;
int finalwidth = texwidth;
@@ -4639,7 +2353,7 @@ INLINE void copyline_yuy16_to_argb(UINT32 *dst, const UINT16 *src, int width, co
// texture_set_data
//============================================================
-static void texture_set_data(d3d_info *d3d, texture_info *texture, const render_texinfo *texsource, UINT32 flags)
+static void texture_set_data(d3d_info *d3d, d3d_texture_info *texture, const render_texinfo *texsource, UINT32 flags)
{
D3DLOCKED_RECT rect;
HRESULT result;
@@ -4723,7 +2437,7 @@ static void texture_set_data(d3d_info *d3d, texture_info *texture, const render_
// texture_prescale
//============================================================
-static void texture_prescale(d3d_info *d3d, texture_info *texture)
+static void texture_prescale(d3d_info *d3d, d3d_texture_info *texture)
{
d3d_surface *surface;
HRESULT result;
@@ -4847,10 +2561,10 @@ static void texture_prescale(d3d_info *d3d, texture_info *texture)
// texture_find
//============================================================
-static texture_info *texture_find(d3d_info *d3d, const render_primitive *prim)
+static d3d_texture_info *texture_find(d3d_info *d3d, const render_primitive *prim)
{
UINT32 texhash = texture_compute_hash(&prim->texture, prim->flags);
- texture_info *texture;
+ d3d_texture_info *texture;
// find a match
for (texture = d3d->texlist; texture != NULL; texture = texture->next)
@@ -4873,7 +2587,7 @@ static texture_info *texture_find(d3d_info *d3d, const render_primitive *prim)
static void texture_update(d3d_info *d3d, const render_primitive *prim)
{
- texture_info *texture = texture_find(d3d, prim);
+ d3d_texture_info *texture = texture_find(d3d, prim);
// if we didn't find one, create a new texture
if (texture == NULL)
@@ -4888,130 +2602,3 @@ static void texture_update(d3d_info *d3d, const render_primitive *prim)
texture->texinfo.seqid = prim->texture.seqid;
}
}
-
-
-// NOTE: The function below is taken directly from src/emu/video.c and should likely be moved into a global helper function.
-//-------------------------------------------------
-// open_next - open the next non-existing file of
-// type filetype according to our numbering
-// scheme
-//-------------------------------------------------
-
-static file_error open_next(d3d_info *d3d, emu_file &file, const char *extension, int idx)
-{
- UINT32 origflags = file.openflags();
-
- // handle defaults
- const char *snapname = d3d->window->machine().options().snap_name();
-
- if (snapname == NULL || snapname[0] == 0)
- snapname = "%g/%i";
- astring snapstr(snapname);
-
- // strip any extension in the provided name
- int index = snapstr.rchr(0, '.');
- if (index != -1)
- snapstr.substr(0, index);
-
- // handle %d in the template (for image devices)
- astring snapdev("%d_");
- int pos = snapstr.find(0, snapdev);
-
- if (pos != -1)
- {
- // if more %d are found, revert to default and ignore them all
- if (snapstr.find(pos + 3, snapdev) != -1)
- snapstr.cpy("%g/%i");
- // else if there is a single %d, try to create the correct snapname
- else
- {
- int name_found = 0;
-
- // find length of the device name
- int end1 = snapstr.find(pos + 3, "/");
- int end2 = snapstr.find(pos + 3, "%");
- int end = -1;
-
- if ((end1 != -1) && (end2 != -1))
- end = MIN(end1, end2);
- else if (end1 != -1)
- end = end1;
- else if (end2 != -1)
- end = end2;
- else
- end = snapstr.len();
-
- if (end - pos < 3)
- fatalerror("Something very wrong is going on!!!");
-
- // copy the device name to an astring
- astring snapdevname;
- snapdevname.cpysubstr(snapstr, pos + 3, end - pos - 3);
-
- // verify that there is such a device for this system
- device_image_interface *image = NULL;
- for (bool gotone = d3d->window->machine().devicelist().first(image); gotone; gotone = image->next(image))
- {
- // get the device name
- astring tempdevname(image->brief_instance_name());
-
- if (snapdevname.cmp(tempdevname) == 0)
- {
- // verify that such a device has an image mounted
- if (image->basename() != NULL)
- {
- astring filename(image->basename());
-
- // strip extension
- filename.substr(0, filename.rchr(0, '.'));
-
- // setup snapname and remove the %d_
- snapstr.replace(0, snapdevname, filename);
- snapstr.del(pos, 3);
-
- name_found = 1;
- }
- }
- }
-
- // or fallback to default
- if (name_found == 0)
- snapstr.cpy("%g/%i");
- }
- }
-
- // add our own index
- // add our own extension
- snapstr.cat(".").cat(extension);
-
- // substitute path and gamename up front
- snapstr.replace(0, "/", PATH_SEPARATOR);
- snapstr.replace(0, "%g", d3d->window->machine().basename());
-
- // determine if the template has an index; if not, we always use the same name
- astring fname;
- if (snapstr.find(0, "%i") == -1)
- fname.cpy(snapstr);
-
- // otherwise, we scan for the next available filename
- else
- {
- // try until we succeed
- astring seqtext;
- file.set_openflags(OPEN_FLAG_READ);
- for (int seq = 0; ; seq++)
- {
- // build up the filename
- fname.cpy(snapstr).replace(0, "%i", seqtext.format("%04d_%d", seq, idx).cstr());
-
- // try to open the file; stop when we fail
- file_error filerr = file.open(fname);
- if (filerr != FILERR_NONE)
- break;
- }
- }
-
- // create the final file
- file.set_openflags(origflags);
- return file.open(fname);
-}