summaryrefslogtreecommitdiffstatshomepage
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
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]
-rw-r--r--.gitattributes4
-rw-r--r--hlsl/yiq_decode.fx2
-rw-r--r--src/osd/windows/d3dcomm.h113
-rw-r--r--src/osd/windows/d3dhlsl.c2481
-rw-r--r--src/osd/windows/d3dhlsl.h221
-rw-r--r--src/osd/windows/drawd3d.c2561
-rw-r--r--src/osd/windows/drawd3d.h127
-rw-r--r--src/osd/windows/windows.mak1
8 files changed, 3022 insertions, 2488 deletions
diff --git a/.gitattributes b/.gitattributes
index 8bce026a717..7cf817c82f4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -4798,10 +4798,14 @@ src/osd/sdl/window.c svneol=native#text/plain
src/osd/sdl/window.h svneol=native#text/plain
src/osd/windows/d3d8intf.c svneol=native#text/plain
src/osd/windows/d3d9intf.c svneol=native#text/plain
+src/osd/windows/d3dcomm.h svneol=native#text/plain
+src/osd/windows/d3dhlsl.c svneol=native#text/plain
+src/osd/windows/d3dhlsl.h svneol=native#text/plain
src/osd/windows/d3dintf.h svneol=native#text/plain
src/osd/windows/debugwin.c svneol=native#text/plain
src/osd/windows/debugwin.h svneol=native#text/plain
src/osd/windows/drawd3d.c svneol=native#text/plain
+src/osd/windows/drawd3d.h svneol=native#text/plain
src/osd/windows/drawdd.c svneol=native#text/plain
src/osd/windows/drawgdi.c svneol=native#text/plain
src/osd/windows/drawnone.c svneol=native#text/plain
diff --git a/hlsl/yiq_decode.fx b/hlsl/yiq_decode.fx
index 346f316464f..c25d9d5405c 100644
--- a/hlsl/yiq_decode.fx
+++ b/hlsl/yiq_decode.fx
@@ -122,7 +122,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float4 CoordX = Input.Coord0.x + Input.Coord0.z * n4 * 0.25f;
float4 CoordY = Input.Coord0.y;
float2 TexCoord = float2(CoordX.r, CoordY.r);
- float4 C = tex2D(CompositeSampler, TexCoord) * CRange + MinC;
+ float4 C = tex2D(CompositeSampler, TexCoord + float2(0.125f, 0.0f) / RawDims) * CRange + MinC;
float4 WT = W * (CoordX * WidthRatio + AValue * CoordY * 2.0f * (RawHeight / HeightRatio) + BValue) + OValue;
float4 SincYIn = PI2 * Fc_y * n4;
diff --git a/src/osd/windows/d3dcomm.h b/src/osd/windows/d3dcomm.h
new file mode 100644
index 00000000000..f000c56866c
--- /dev/null
+++ b/src/osd/windows/d3dcomm.h
@@ -0,0 +1,113 @@
+//============================================================
+//
+// d3dcomm.h - Common Win32 Direct3D structures
+//
+//============================================================
+//
+// Copyright Aaron Giles
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or
+// without modification, are permitted provided that the
+// following conditions are met:
+//
+// * Redistributions of source code must retain the above
+// copyright notice, this list of conditions and the
+// following disclaimer.
+// * Redistributions in binary form must reproduce the
+// above copyright notice, this list of conditions and
+// the following disclaimer in the documentation and/or
+// other materials provided with the distribution.
+// * Neither the name 'MAME' nor the names of its
+// contributors may be used to endorse or promote
+// products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGE (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//============================================================
+
+#ifndef __WIN_D3DCOMM__
+#define __WIN_D3DCOMM__
+
+//============================================================
+// CONSTANTS
+//============================================================
+
+
+
+//============================================================
+// TYPE DEFINITIONS
+//============================================================
+
+/* d3d_texture_info holds information about a texture */
+typedef struct _d3d_texture_info d3d_texture_info;
+struct _d3d_texture_info
+{
+ d3d_texture_info * next; // next texture in the list
+ d3d_texture_info * prev; // prev texture in the list
+ UINT32 hash; // hash value for the texture
+ UINT32 flags; // rendering flags
+ render_texinfo texinfo; // copy of the texture info
+ float ustart, ustop; // beginning/ending U coordinates
+ float vstart, vstop; // beginning/ending V coordinates
+ int rawwidth, rawheight; // raw width/height of the texture
+ int type; // what type of texture are we?
+ int xborderpix; // number of border pixels in X
+ int yborderpix; // number of border pixels in Y
+ int xprescale; // what is our X prescale factor?
+ int yprescale; // what is our Y prescale factor?
+ int cur_frame; // what is our current frame?
+ 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
+};
+
+
+/* d3d_poly_info holds information about a single polygon/d3d primitive */
+typedef struct _d3d_poly_info d3d_poly_info;
+struct _d3d_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
+ d3d_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
+};
+
+
+/* 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
+};
+
+
+#endif
diff --git a/src/osd/windows/d3dhlsl.c b/src/osd/windows/d3dhlsl.c
new file mode 100644
index 00000000000..356614feb62
--- /dev/null
+++ b/src/osd/windows/d3dhlsl.c
@@ -0,0 +1,2481 @@
+//============================================================
+//
+// drawd3d.c - Win32 Direct3D HLSL implementation
+//
+//============================================================
+//
+// Copyright Aaron Giles
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or
+// without modification, are permitted provided that the
+// following conditions are met:
+//
+// * Redistributions of source code must retain the above
+// copyright notice, this list of conditions and the
+// following disclaimer.
+// * Redistributions in binary form must reproduce the
+// above copyright notice, this list of conditions and
+// the following disclaimer in the documentation and/or
+// other materials provided with the distribution.
+// * Neither the name 'MAME' nor the names of its
+// contributors may be used to endorse or promote
+// products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGE (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//============================================================
+
+// Useful info:
+// Windows XP/2003 shipped with DirectX 8.1
+// Windows 2000 shipped with DirectX 7a
+// Windows 98SE shipped with DirectX 6.1a
+// Windows 98 shipped with DirectX 5
+// Windows NT shipped with DirectX 3.0a
+// Windows 95 shipped with DirectX 2
+
+// standard windows headers
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <tchar.h>
+#include <mmsystem.h>
+#include <d3d9.h>
+#include <d3dx9.h>
+#include <math.h>
+#undef interface
+
+// MAME headers
+#include "emu.h"
+#include "render.h"
+#include "ui.h"
+#include "rendutil.h"
+#include "options.h"
+#include "emuopts.h"
+#include "aviio.h"
+#include "png.h"
+
+// MAMEOS headers
+#include "d3dintf.h"
+#include "winmain.h"
+#include "window.h"
+#include "config.h"
+#include "strconv.h"
+#include "d3dcomm.h"
+#include "drawd3d.h"
+
+
+
+//============================================================
+// GLOBALS
+//============================================================
+
+static hlsl_options g_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 }
+};
+
+static slider_state *g_slider_list;
+
+
+
+//============================================================
+// PROTOTYPES
+//============================================================
+
+static file_error open_next(d3d_info *d3d, emu_file &file, const char *extension, int idx);
+
+
+
+//============================================================
+// hlsl_info constructor
+//============================================================
+
+hlsl_info::hlsl_info()
+{
+ master_enable = false;
+ yiq_enable = false;
+ prescale_size = 1;
+ preset = -1;
+ shadow_bitmap = NULL;
+ shadow_texture = NULL;
+ registered_targets = 0;
+ options = NULL;
+
+}
+
+
+
+//============================================================
+// hlsl_info destructor
+//============================================================
+
+hlsl_info::~hlsl_info()
+{
+ master_enable = false;
+ yiq_enable = false;
+ prescale_size = 1;
+ preset = -1;
+ shadow_bitmap = NULL;
+ shadow_texture = NULL;
+ registered_targets = 0;
+ options = NULL;
+
+}
+
+
+
+//============================================================
+// hlsl_info::window_save
+//============================================================
+
+void hlsl_info::window_save()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ HRESULT result = (*d3dintf->device.create_texture)(d3d->device, snap_width, snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &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)(snap_copy_texture, 0, &snap_copy_target);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, snap_width, snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &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)(snap_texture, 0, &snap_target);
+
+ render_snap = true;
+ snap_rendered = false;
+}
+
+
+
+//============================================================
+// hlsl_info::window_record
+//============================================================
+
+void hlsl_info::window_record()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ windows_options &options = downcast<windows_options &>(window->machine().options());
+ const char *filename = options.d3d_hlsl_write();
+
+ if (avi_output_file != NULL)
+ end_avi_recording();
+ else if (filename[0] != 0)
+ begin_avi_recording(filename);
+}
+
+
+//============================================================
+// hlsl_info::avi_update_snap
+//============================================================
+
+void hlsl_info::avi_update_snap(d3d_surface *surface)
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ D3DLOCKED_RECT rect;
+
+ // if we don't have a bitmap, or if it's not the right size, allocate a new one
+ if (avi_snap == NULL || (int)snap_width != avi_snap->width || (int)snap_height != avi_snap->height)
+ {
+ if (avi_snap != NULL)
+ {
+ auto_free(window->machine(), avi_snap);
+ }
+ avi_snap = auto_alloc(window->machine(), bitmap_t((int)snap_width, (int)snap_height, BITMAP_FORMAT_RGB32));
+ }
+
+ // copy the texture
+ HRESULT result = (*d3dintf->device.get_render_target_data)(d3d->device, surface, avi_copy_surface);
+ if (result != D3D_OK)
+ {
+ printf("Couldn't copy (%08x)\n", (UINT32)result);
+ return;
+ }
+
+ // lock the texture
+ result = (*d3dintf->surface.lock_rect)(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)snap_height; srcy++)
+ {
+ BYTE *src = (BYTE *)rect.pBits + srcy * rect.Pitch;
+ BYTE *dst = (BYTE *)avi_snap->base + srcy * avi_snap->rowpixels * 4;
+
+ for(int x = 0; x < snap_width; x++)
+ {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ }
+ }
+
+ // unlock
+ result = (*d3dintf->surface.unlock_rect)(avi_copy_surface);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during texture unlock_rect call\n", (int)result);
+}
+
+
+
+//============================================================
+// hlsl_render_snapshot
+//============================================================
+
+void hlsl_info::render_snapshot(d3d_surface *surface)
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ D3DLOCKED_RECT rect;
+
+ render_snap = false;
+
+ // if we don't have a bitmap, or if it's not the right size, allocate a new one
+ if (avi_snap == NULL || snap_width != (avi_snap->width / 2) || snap_height != (avi_snap->height / 2))
+ {
+ if (avi_snap != NULL)
+ {
+ auto_free(window->machine(), avi_snap);
+ }
+ avi_snap = auto_alloc(window->machine(), bitmap_t(snap_width / 2, snap_height / 2, BITMAP_FORMAT_RGB32));
+ }
+
+ // copy the texture
+ HRESULT result = (*d3dintf->device.get_render_target_data)(d3d->device, surface, snap_copy_target);
+ if (result != D3D_OK)
+ {
+ printf("Couldn't copy (%08x)\n", (UINT32)result);
+ return;
+ }
+
+ // lock the texture
+ result = (*d3dintf->surface.lock_rect)(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 < snap_height / 2; srcy++)
+ {
+ int toty = (srcy + cy * (snap_height / 2));
+ int totx = cx * (snap_width / 2);
+ BYTE *src = (BYTE *)rect.pBits + toty * rect.Pitch + totx * 4;
+ BYTE *dst = (BYTE *)avi_snap->base + srcy * avi_snap->rowpixels * 4;
+
+ for(int x = 0; x < snap_width / 2; x++)
+ {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ }
+ }
+
+ int idx = cy * 2 + cx;
+
+ emu_file file(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(window->machine().system().manufacturer, " ", 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, 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)(snap_copy_target);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during texture unlock_rect call\n", (int)result);
+
+ if(snap_texture != NULL)
+ {
+ (*d3dintf->texture.release)(snap_texture);
+ snap_texture = NULL;
+ }
+
+ if(snap_target != NULL)
+ {
+ (*d3dintf->surface.release)(snap_target);
+ snap_target = NULL;
+ }
+
+ if(snap_copy_texture != NULL)
+ {
+ (*d3dintf->texture.release)(snap_copy_texture);
+ snap_copy_texture = NULL;
+ }
+
+ if(snap_copy_target != NULL)
+ {
+ (*d3dintf->surface.release)(snap_copy_target);
+ snap_copy_target = NULL;
+ }
+}
+
+
+//============================================================
+// hlsl_info::record_texture
+//============================================================
+
+void hlsl_info::record_texture()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_surface *surface = avi_final_target;
+
+ // ignore if nothing to do
+ if (avi_output_file == NULL || surface == NULL)
+ return;
+
+ // get the current time
+ attotime curtime = window->machine().time();
+
+ avi_update_snap(surface);
+
+ // loop until we hit the right time
+ while (avi_next_frame_time <= curtime)
+ {
+ // handle an AVI recording
+ // write the next frame
+ avi_error avierr = avi_append_video_frame_rgb32(avi_output_file, avi_snap);
+ if (avierr != AVIERR_NONE)
+ {
+ end_avi_recording();
+ return;
+ }
+
+ // advance time
+ avi_next_frame_time += avi_frame_period;
+ avi_frame++;
+ }
+}
+
+
+//============================================================
+// hlsl_info::frame_complete
+//============================================================
+
+void hlsl_info::frame_complete()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ if(render_snap && snap_rendered)
+ {
+ render_snapshot(snap_target);
+ }
+}
+
+
+//============================================================
+// hlsl_info::end_hlsl_avi_recording
+//============================================================
+
+void hlsl_info::end_avi_recording()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ if (avi_output_file != NULL)
+ avi_close(avi_output_file);
+
+ avi_output_file = NULL;
+ avi_frame = 0;
+}
+
+
+//============================================================
+// hlsl_info::begin_avi_recording
+//============================================================
+
+void hlsl_info::begin_avi_recording(const char *name)
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ // stop any existing recording
+ end_avi_recording();
+
+ // reset the state
+ avi_frame = 0;
+ avi_next_frame_time = window->machine().time();
+
+ // build up information about this new movie
+ avi_movie_info info;
+ info.video_format = 0;
+ info.video_timescale = 1000 * ((window->machine().primary_screen != NULL) ? ATTOSECONDS_TO_HZ(window->machine().primary_screen->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE);
+ info.video_sampletime = 1000;
+ info.video_numsamples = 0;
+ info.video_width = snap_width;
+ info.video_height = snap_height;
+ info.video_depth = 24;
+
+ info.audio_format = 0;
+ info.audio_timescale = window->machine().sample_rate();
+ info.audio_sampletime = 1;
+ info.audio_numsamples = 0;
+ info.audio_channels = 2;
+ info.audio_samplebits = 16;
+ info.audio_samplerate = window->machine().sample_rate();
+
+ // create a new temporary movie file
+ file_error filerr;
+ astring fullpath;
+ {
+ emu_file tempfile(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
+ {
+ 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, &avi_output_file);
+ if (avierr != AVIERR_NONE)
+ {
+ mame_printf_error("Error creating AVI: %s\n", avi_error_string(avierr));
+ }
+ }
+}
+
+
+//============================================================
+// hlsl_info::set_texture
+//============================================================
+
+void hlsl_info::set_texture(d3d_texture_info *texture)
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ (*d3dintf->effect.set_texture)(effect, "Diffuse", (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
+ if (yiq_enable)
+ (*d3dintf->effect.set_texture)(yiq_encode_effect, "Diffuse", (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
+ else
+ (*d3dintf->effect.set_texture)(color_effect, "Diffuse", (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
+ (*d3dintf->effect.set_texture)(pincushion_effect, "Diffuse", (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
+}
+
+
+//============================================================
+// hlsl_info::init
+//============================================================
+
+void hlsl_info::init(d3d *d3dintf, win_window_info *window)
+{
+ if (!d3dintf->post_fx_available)
+ return;
+
+ this->d3dintf = d3dintf;
+ this->window = window;
+
+ master_enable = downcast<windows_options &>(window->machine().options()).d3d_hlsl_enable();
+ yiq_enable = downcast<windows_options &>(window->machine().options()).screen_yiq_enable();
+ prescale_size = 1;
+ preset = downcast<windows_options &>(window->machine().options()).d3d_hlsl_preset();
+
+ snap_width = downcast<windows_options &>(window->machine().options()).d3d_snap_width();
+ snap_height = downcast<windows_options &>(window->machine().options()).d3d_snap_height();
+}
+
+
+//============================================================
+// hlsl_info::init_fsfx_quad
+//============================================================
+
+void hlsl_info::init_fsfx_quad(void *vertbuf)
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ // get a pointer to the vertex buffer
+ fsfx_vertices = (d3d_vertex *)vertbuf;
+ if (fsfx_vertices == NULL)
+ return;
+
+ // fill in the vertexes clockwise
+ windows_options &options = downcast<windows_options &>(window->machine().options());
+ float scale_top = options.screen_scale_top();
+ float scale_bottom = options.screen_scale_bottom();
+
+ fsfx_vertices[0].x = (d3d->width * (scale_top * 0.5f - 0.5f));
+ fsfx_vertices[0].y = 0.0f;
+ fsfx_vertices[1].x = d3d->width - (d3d->width * (scale_top * 0.5f - 0.5f));
+ fsfx_vertices[1].y = 0.0f;
+ fsfx_vertices[2].x = (d3d->width * (scale_bottom * 0.5f - 0.5f));
+ fsfx_vertices[2].y = d3d->height;
+ fsfx_vertices[3].x = d3d->width - (d3d->width * (scale_bottom * 0.5f - 0.5f));
+ fsfx_vertices[3].y = d3d->height;
+
+ fsfx_vertices[0].u0 = 0.0f;
+ fsfx_vertices[0].v0 = 0.0f;
+ fsfx_vertices[1].u0 = 1.0f;
+ fsfx_vertices[1].v0 = 0.0f;
+ fsfx_vertices[2].u0 = 0.0f;
+ fsfx_vertices[2].v0 = 1.0f;
+ fsfx_vertices[3].u0 = 1.0f;
+ fsfx_vertices[3].v0 = 1.0f;
+
+ // set the color, Z parameters to standard values
+ for (int i = 0; i < 4; i++)
+ {
+ fsfx_vertices[i].z = 0.0f;
+ fsfx_vertices[i].rhw = 1.0f;
+ fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);
+ }
+}
+
+
+//============================================================
+// hlsl_info::create_resources
+//============================================================
+
+int hlsl_info::create_resources()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return 0;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ HRESULT result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &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)(avi_copy_texture, 0, &avi_copy_surface);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &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)(avi_final_texture, 0, &avi_final_target);
+
+ windows_options &winoptions = downcast<windows_options &>(window->machine().options());
+
+ // experimental: load a PNG to use for vector rendering; it is treated
+ // as a brightness map
+ emu_file file(window->machine().options().art_path(), OPEN_FLAG_READ);
+ shadow_bitmap = render_load_png(file, NULL, winoptions.screen_shadow_mask_texture(), NULL, NULL);
+
+ // experimental: if we have a shadow bitmap, create a texture for it
+ if (shadow_bitmap != NULL)
+ {
+ render_texinfo texture;
+
+ // fake in the basic data so it looks like it came from render.c
+ texture.base = shadow_bitmap->base;
+ texture.rowpixels = shadow_bitmap->rowpixels;
+ texture.width = shadow_bitmap->width;
+ texture.height = shadow_bitmap->height;
+ texture.palette = NULL;
+ texture.seqid = 0;
+
+ // now create it
+ shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
+ }
+
+ options = (hlsl_options*)global_alloc_clear(hlsl_options);
+
+ if(preset == -1)
+ {
+ options->shadow_mask_alpha = winoptions.screen_shadow_mask_alpha();
+ options->shadow_mask_count_x = winoptions.screen_shadow_mask_count_x();
+ options->shadow_mask_count_y = winoptions.screen_shadow_mask_count_y();
+ options->shadow_mask_u_size = winoptions.screen_shadow_mask_u_size();
+ options->shadow_mask_v_size = winoptions.screen_shadow_mask_v_size();
+ options->curvature = winoptions.screen_curvature();
+ options->pincushion = winoptions.screen_pincushion();
+ options->scanline_alpha = winoptions.screen_scanline_amount();
+ options->scanline_scale = winoptions.screen_scanline_scale();
+ options->scanline_height = winoptions.screen_scanline_height();
+ options->scanline_bright_scale = winoptions.screen_scanline_bright_scale();
+ options->scanline_bright_offset = winoptions.screen_scanline_bright_offset();
+ options->scanline_offset = winoptions.screen_scanline_offset();
+ options->defocus_x = winoptions.screen_defocus_x();
+ options->defocus_y = winoptions.screen_defocus_y();
+ options->red_converge_x = winoptions.screen_red_converge_x();
+ options->red_converge_y = winoptions.screen_red_converge_y();
+ options->green_converge_x = winoptions.screen_green_converge_x();
+ options->green_converge_y = winoptions.screen_green_converge_y();
+ options->blue_converge_x = winoptions.screen_blue_converge_x();
+ options->blue_converge_y = winoptions.screen_blue_converge_y();
+ options->red_radial_converge_x = winoptions.screen_red_radial_converge_x();
+ options->red_radial_converge_y = winoptions.screen_red_radial_converge_y();
+ options->green_radial_converge_x = winoptions.screen_green_radial_converge_x();
+ options->green_radial_converge_y = winoptions.screen_green_radial_converge_y();
+ options->blue_radial_converge_x = winoptions.screen_blue_radial_converge_x();
+ options->blue_radial_converge_y = winoptions.screen_blue_radial_converge_y();
+ options->red_from_red = winoptions.screen_red_from_red();
+ options->red_from_green = winoptions.screen_red_from_green();
+ options->red_from_blue = winoptions.screen_red_from_blue();
+ options->green_from_red = winoptions.screen_green_from_red();
+ options->green_from_green = winoptions.screen_green_from_green();
+ options->green_from_blue = winoptions.screen_green_from_blue();
+ options->blue_from_red = winoptions.screen_blue_from_red();
+ options->blue_from_green = winoptions.screen_blue_from_green();
+ options->blue_from_blue = winoptions.screen_blue_from_blue();
+ options->red_offset = winoptions.screen_red_offset();
+ options->green_offset = winoptions.screen_green_offset();
+ options->blue_offset = winoptions.screen_blue_offset();
+ options->red_scale = winoptions.screen_red_scale();
+ options->green_scale = winoptions.screen_green_scale();
+ options->blue_scale = winoptions.screen_blue_scale();
+ options->red_power = winoptions.screen_red_power();
+ options->green_power = winoptions.screen_green_power();
+ options->blue_power = winoptions.screen_blue_power();
+ options->red_floor = winoptions.screen_red_floor();
+ options->green_floor = winoptions.screen_green_floor();
+ options->blue_floor = winoptions.screen_blue_floor();
+ options->red_phosphor_life = winoptions.screen_red_phosphor();
+ options->green_phosphor_life = winoptions.screen_green_phosphor();
+ options->blue_phosphor_life = winoptions.screen_blue_phosphor();
+ options->saturation = winoptions.screen_saturation();
+ }
+ else
+ {
+ options = &g_hlsl_presets[preset];
+ }
+
+ g_slider_list = init_slider_list();
+
+ 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, &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, &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, &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, &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, &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, &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, &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, &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, &yiq_encode_effect);
+ if(result != D3D_OK)
+ {
+ printf("Direct3D: Unable to load yiq_encode.fx\n");
+ return 1;
+ }
+
+ // create the YIQ demodulation shader
+ result = (*d3dintf->device.create_effect)(d3d->device, yiq_decode_name, &yiq_decode_effect);
+ if(result != D3D_OK)
+ {
+ printf("Direct3D: Unable to load yiq_decode.fx\n");
+ return 1;
+ }
+
+ 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);
+
+ return 0;
+}
+
+
+//============================================================
+// hlsl_info::begin
+//============================================================
+
+void hlsl_info::begin()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ curr_effect = effect;
+
+ (*d3dintf->effect.set_technique)(effect, "TestTechnique");
+ (*d3dintf->effect.set_technique)(post_effect, "ScanMaskTechnique");
+ (*d3dintf->effect.set_technique)(pincushion_effect, "TestTechnique");
+ (*d3dintf->effect.set_technique)(phosphor_effect, "TestTechnique");
+ (*d3dintf->effect.set_technique)(focus_effect, "TestTechnique");
+ (*d3dintf->effect.set_technique)(deconverge_effect, "DeconvergeTechnique");
+ (*d3dintf->effect.set_technique)(color_effect, "ColorTechnique");
+ (*d3dintf->effect.set_technique)(yiq_encode_effect, "EncodeTechnique");
+ (*d3dintf->effect.set_technique)(yiq_decode_effect, "DecodeTechnique");
+
+ HRESULT 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);
+
+ for (int index = 0; index < 9; index++)
+ screen_encountered[index] = false;
+}
+
+
+//============================================================
+// hlsl_info::render_quad
+//============================================================
+
+void hlsl_info::init_effect_info(d3d_poly_info *poly)
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ if(PRIMFLAG_GET_TEXSHADE(d3d->last_texture_flags))
+ {
+ curr_effect = 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 = 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)prescale_size);
+ (*d3dintf->effect.set_float)(curr_effect, "RedFloor", options->red_floor);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnFloor", options->green_floor);
+ (*d3dintf->effect.set_float)(curr_effect, "BluFloor", options->blue_floor);
+ (*d3dintf->effect.set_float)(curr_effect, "SnapX", snap_width);
+ (*d3dintf->effect.set_float)(curr_effect, "SnapY", snap_height);
+ (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion);
+ (*d3dintf->effect.set_float)(curr_effect, "CurvatureAmount", options->curvature);
+ (*d3dintf->effect.set_float)(curr_effect, "UseShadow", shadow_texture == NULL ? 0.0f : 1.0f);
+ (*d3dintf->effect.set_texture)(curr_effect, "Shadow", shadow_texture == NULL ? NULL : shadow_texture->d3dfinaltex);
+ (*d3dintf->effect.set_float)(curr_effect, "ShadowBrightness", options->shadow_mask_alpha);
+ (*d3dintf->effect.set_float)(curr_effect, "ShadowMaskSizeX", (float)options->shadow_mask_count_x);
+ (*d3dintf->effect.set_float)(curr_effect, "ShadowMaskSizeY", (float)options->shadow_mask_count_y);
+ (*d3dintf->effect.set_float)(curr_effect, "ShadowU", options->shadow_mask_u_size);
+ (*d3dintf->effect.set_float)(curr_effect, "ShadowV", options->shadow_mask_v_size);
+ (*d3dintf->effect.set_float)(curr_effect, "ShadowWidth", shadow_texture == NULL ? 1.0f : (float)shadow_texture->rawwidth);
+ (*d3dintf->effect.set_float)(curr_effect, "ShadowHeight", shadow_texture == NULL ? 1.0f : (float)shadow_texture->rawheight);
+ (*d3dintf->effect.set_float)(curr_effect, "ScanlineAmount", options->scanline_alpha);
+ (*d3dintf->effect.set_float)(curr_effect, "ScanlineScale", options->scanline_scale);
+ (*d3dintf->effect.set_float)(curr_effect, "ScanlineHeight", options->scanline_height);
+ (*d3dintf->effect.set_float)(curr_effect, "ScanlineBrightScale", options->scanline_bright_scale);
+ (*d3dintf->effect.set_float)(curr_effect, "ScanlineBrightOffset", options->scanline_bright_offset);
+ (*d3dintf->effect.set_float)(curr_effect, "ScanlineOffset", (poly->texture->cur_frame == 0) ? 0.0f : options->scanline_offset);
+ }
+ else
+ {
+ curr_effect = effect;
+
+ (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f);
+ }
+}
+
+
+//============================================================
+// hlsl_info::render_quad
+//============================================================
+
+void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ UINT num_passes = 0;
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ windows_options &winoptions = downcast<windows_options &>(window->machine().options());
+
+ if(PRIMFLAG_GET_SCREENTEX(d3d->last_texture_flags) && poly->texture != NULL)
+ {
+ screen_encountered[poly->texture->target_index] = true;
+ target_in_use[poly->texture->target_index] = poly->texture;
+
+ target_use_count[poly->texture->target_index] = 60;
+
+ if(yiq_enable)
+ {
+ /* Convert our signal into YIQ */
+ curr_effect = 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)prescale_size);
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, target4[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 = yiq_decode_effect;
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Composite", texture4[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)prescale_size);
+
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, target3[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 = color_effect;
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture3[poly->texture->target_index]);
+ }
+
+ curr_effect = 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", yiq_enable ? 1.0f : (1.0f / (poly->texture->ustop - poly->texture->ustart)));
+ (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 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", yiq_enable ? 1.0f : 0.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "RedFromRed", options->red_from_red);
+ (*d3dintf->effect.set_float)(curr_effect, "RedFromGrn", options->red_from_green);
+ (*d3dintf->effect.set_float)(curr_effect, "RedFromBlu", options->red_from_blue);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnFromRed", options->green_from_red);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnFromGrn", options->green_from_green);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnFromBlu", options->green_from_blue);
+ (*d3dintf->effect.set_float)(curr_effect, "BluFromRed", options->blue_from_red);
+ (*d3dintf->effect.set_float)(curr_effect, "BluFromGrn", options->blue_from_green);
+ (*d3dintf->effect.set_float)(curr_effect, "BluFromBlu", options->blue_from_blue);
+ (*d3dintf->effect.set_float)(curr_effect, "RedOffset", options->red_offset);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnOffset", options->green_offset);
+ (*d3dintf->effect.set_float)(curr_effect, "BluOffset", options->blue_offset);
+ (*d3dintf->effect.set_float)(curr_effect, "RedScale", options->red_scale);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnScale", options->green_scale);
+ (*d3dintf->effect.set_float)(curr_effect, "BluScale", options->blue_scale);
+ (*d3dintf->effect.set_float)(curr_effect, "RedPower", options->red_power);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnPower", options->green_power);
+ (*d3dintf->effect.set_float)(curr_effect, "BluPower", options->blue_power);
+ (*d3dintf->effect.set_float)(curr_effect, "Saturation", options->saturation);
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, smalltarget0[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 = prescale_effect;
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", smalltexture0[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, prescaletarget0[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 = deconverge_effect;
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", prescaletexture0[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", prescale_size);
+ (*d3dintf->effect.set_float)(curr_effect, "RedConvergeX", options->red_converge_x);
+ (*d3dintf->effect.set_float)(curr_effect, "RedConvergeY", options->red_converge_y);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnConvergeX", options->green_converge_x);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnConvergeY", options->green_converge_y);
+ (*d3dintf->effect.set_float)(curr_effect, "BluConvergeX", options->blue_converge_x);
+ (*d3dintf->effect.set_float)(curr_effect, "BluConvergeY", options->blue_converge_y);
+ (*d3dintf->effect.set_float)(curr_effect, "RedRadialConvergeX", options->red_radial_converge_x);
+ (*d3dintf->effect.set_float)(curr_effect, "RedRadialConvergeY", options->red_radial_converge_y);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnRadialConvergeX", options->green_radial_converge_x);
+ (*d3dintf->effect.set_float)(curr_effect, "GrnRadialConvergeY", options->green_radial_converge_y);
+ (*d3dintf->effect.set_float)(curr_effect, "BluRadialConvergeX", options->blue_radial_converge_x);
+ (*d3dintf->effect.set_float)(curr_effect, "BluRadialConvergeY", options->blue_radial_converge_y);
+
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, target2[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->defocus_x;
+ float defocus_y = options->defocus_y;
+ bool focus_enable = defocus_x != 0.0f || defocus_y != 0.0f;
+ if(focus_enable)
+ {
+ /* Defocus pass 1 */
+ curr_effect = focus_effect;
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture2[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, target0[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", texture0[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, target1[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 = 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->red_phosphor_life);
+ (*d3dintf->effect.set_float)(curr_effect, "GreenPhosphor", options->green_phosphor_life);
+ (*d3dintf->effect.set_float)(curr_effect, "BluePhosphor", options->blue_phosphor_life);
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", focus_enable ? texture1[poly->texture->target_index] : texture2[poly->texture->target_index]);
+ (*d3dintf->effect.set_texture)(curr_effect, "LastPass", last_texture[poly->texture->target_index]);
+
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, target0[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 = phosphor_effect;
+
+ (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f);
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", focus_enable ? texture1[poly->texture->target_index] : texture2[poly->texture->target_index]);
+ (*d3dintf->effect.set_texture)(curr_effect, "LastPass", focus_enable ? texture1[poly->texture->target_index] : texture2[poly->texture->target_index]);
+
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, last_target[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(avi_output_file != NULL)
+ {
+ curr_effect = post_effect;
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[poly->texture->target_index]);
+
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, 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
+ HRESULT 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(render_snap)
+ {
+ curr_effect = post_effect;
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[poly->texture->target_index]);
+
+ (*d3dintf->effect.set_float)(curr_effect, "SnapX", snap_width);
+ (*d3dintf->effect.set_float)(curr_effect, "SnapY", snap_height);
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, 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
+ HRESULT 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);
+
+ 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 = post_effect;
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[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
+ HRESULT 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->pincushion);
+ (*d3dintf->effect.set_float)(curr_effect, "PincushionAmountY", options->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
+ HRESULT 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);
+ }
+}
+
+
+
+//============================================================
+// hlsl_info::end
+//============================================================
+
+void hlsl_info::end()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ (*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 && master_enable && d3dintf->post_fx_available; index++)
+ {
+ if(!screen_encountered[index] && smalltarget0[index] != NULL)
+ {
+ if(target_use_count[index] > 0)
+ {
+ target_use_count[index]--;
+ }
+ else
+ {
+ // free all textures
+ if(target_in_use[index] != NULL)
+ {
+ d3d_texture_info *tex = 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 (prescaletexture0[index] != NULL)
+ {
+ (*d3dintf->texture.release)(prescaletexture0[index]);
+ prescaletexture0[index] = NULL;
+ }
+ if (texture0[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture0[index]);
+ texture0[index] = NULL;
+ }
+ if (texture1[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture1[index]);
+ texture1[index] = NULL;
+ }
+ if (texture2[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture2[index]);
+ texture2[index] = NULL;
+ }
+ if (texture3[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture3[index]);
+ texture3[index] = NULL;
+ }
+ if (texture4[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture4[index]);
+ texture4[index] = NULL;
+ }
+ if (smalltexture0[index] != NULL)
+ {
+ (*d3dintf->texture.release)(smalltexture0[index]);
+ smalltexture0[index] = NULL;
+ }
+ if (prescaletarget0[index] != NULL)
+ {
+ (*d3dintf->surface.release)(prescaletarget0[index]);
+ prescaletarget0[index] = NULL;
+ }
+ if (target0[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target0[index]);
+ target0[index] = NULL;
+ }
+ if (target1[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target1[index]);
+ target1[index] = NULL;
+ }
+ if (target2[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target2[index]);
+ target2[index] = NULL;
+ }
+ if (target3[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target3[index]);
+ target3[index] = NULL;
+ }
+ if (target4[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target4[index]);
+ target4[index] = NULL;
+ }
+ if (smalltarget0[index] != NULL)
+ {
+ (*d3dintf->surface.release)(smalltarget0[index]);
+ smalltarget0[index] = NULL;
+ }
+ if(last_texture[index] != NULL)
+ {
+ (*d3dintf->texture.release)(last_texture[index]);
+ last_texture[index] = NULL;
+ }
+ if(last_target[index] != NULL)
+ {
+ (*d3dintf->surface.release)(last_target[index]);
+ last_target[index] = NULL;
+ }
+ target_use_count[index] = 0;
+ }
+ }
+ }
+}
+
+
+//============================================================
+// hlsl_info::register_texture
+//============================================================
+
+int hlsl_info::register_prescaled_texture(d3d_texture_info *texture, int scwidth, int scheight)
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return 0;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ int idx = 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++;
+ while(texture->rawheight * hlsl_prescale < d3d->height) hlsl_prescale++;
+ prescale_size = hlsl_prescale;
+
+ HRESULT result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture0[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture0[idx], 0, &target0[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture1[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture1[idx], 0, &target1[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture2[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture2[idx], 0, &target2[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture3[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture3[idx], 0, &target3[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture4[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture4[idx], 0, &target4[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &smalltexture0[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(smalltexture0[idx], 0, &smalltarget0[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &prescaletexture0[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(prescaletexture0[idx], 0, &prescaletarget0[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, d3d->width, d3d->height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &last_texture[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(last_texture[idx], 0, &last_target[idx]);
+
+ texture->target_index = registered_targets;
+ target_use_count[texture->target_index] = 60;
+ target_in_use[texture->target_index] = texture;
+ registered_targets++;
+ registered_targets %= 9;
+
+ return 0;
+}
+
+//============================================================
+// hlsl_info::register_texture
+//============================================================
+
+int hlsl_info::register_texture(d3d_texture_info *texture)
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return 0;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ int idx = 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++;
+ while(texture->rawheight * hlsl_prescale < d3d->height) hlsl_prescale++;
+ prescale_size = hlsl_prescale;
+
+ HRESULT result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture0[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture0[idx], 0, &target0[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture1[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture1[idx], 0, &target1[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture2[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture2[idx], 0, &target2[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture3[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture3[idx], 0, &target3[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture4[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(texture4[idx], 0, &target4[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &smalltexture0[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(smalltexture0[idx], 0, &smalltarget0[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &prescaletexture0[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(prescaletexture0[idx], 0, &prescaletarget0[idx]);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, d3d->width, d3d->height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &last_texture[idx]);
+ if (result != D3D_OK)
+ return 1;
+ (*d3dintf->texture.get_surface_level)(last_texture[idx], 0, &last_target[idx]);
+
+ texture->target_index = registered_targets;
+ target_use_count[texture->target_index] = 60;
+ target_in_use[texture->target_index] = texture;
+ registered_targets++;
+ registered_targets %= 9;
+
+ return 0;
+}
+
+//============================================================
+// hlsl_info::delete_resources
+//============================================================
+
+void hlsl_info::delete_resources()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ if (effect != NULL)
+ {
+ (*d3dintf->effect.release)(effect);
+ effect = NULL;
+ }
+ if (post_effect != NULL)
+ {
+ (*d3dintf->effect.release)(post_effect);
+ post_effect = NULL;
+ }
+ if (prescale_effect != NULL)
+ {
+ (*d3dintf->effect.release)(prescale_effect);
+ prescale_effect = NULL;
+ }
+ if (pincushion_effect != NULL)
+ {
+ (*d3dintf->effect.release)(pincushion_effect);
+ pincushion_effect = NULL;
+ }
+ if (phosphor_effect != NULL)
+ {
+ (*d3dintf->effect.release)(phosphor_effect);
+ phosphor_effect = NULL;
+ }
+ if (focus_effect != NULL)
+ {
+ (*d3dintf->effect.release)(focus_effect);
+ focus_effect = NULL;
+ }
+ if (deconverge_effect != NULL)
+ {
+ (*d3dintf->effect.release)(deconverge_effect);
+ deconverge_effect = NULL;
+ }
+ if (color_effect != NULL)
+ {
+ (*d3dintf->effect.release)(color_effect);
+ color_effect = NULL;
+ }
+ if (yiq_encode_effect != NULL)
+ {
+ (*d3dintf->effect.release)(yiq_encode_effect);
+ yiq_encode_effect = NULL;
+ }
+ if (yiq_decode_effect != NULL)
+ {
+ (*d3dintf->effect.release)(yiq_decode_effect);
+ yiq_decode_effect = NULL;
+ }
+
+ for (int index = 0; index < 9; index++)
+ {
+ if (prescaletexture0[index] != NULL)
+ {
+ (*d3dintf->texture.release)(prescaletexture0[index]);
+ prescaletexture0[index] = NULL;
+ }
+ if (texture0[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture0[index]);
+ texture0[index] = NULL;
+ }
+ if (texture1[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture1[index]);
+ texture1[index] = NULL;
+ }
+ if (texture2[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture2[index]);
+ texture2[index] = NULL;
+ }
+ if (texture3[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture3[index]);
+ texture3[index] = NULL;
+ }
+ if (texture4[index] != NULL)
+ {
+ (*d3dintf->texture.release)(texture4[index]);
+ texture4[index] = NULL;
+ }
+ if (smalltexture0[index] != NULL)
+ {
+ (*d3dintf->texture.release)(smalltexture0[index]);
+ smalltexture0[index] = NULL;
+ }
+ if (prescaletarget0[index] != NULL)
+ {
+ (*d3dintf->surface.release)(prescaletarget0[index]);
+ prescaletarget0[index] = NULL;
+ }
+ if (target0[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target0[index]);
+ target0[index] = NULL;
+ }
+ if (target1[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target1[index]);
+ target1[index] = NULL;
+ }
+ if (target2[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target2[index]);
+ target2[index] = NULL;
+ }
+ if (target3[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target3[index]);
+ target3[index] = NULL;
+ }
+ if (target4[index] != NULL)
+ {
+ (*d3dintf->surface.release)(target4[index]);
+ target4[index] = NULL;
+ }
+ if (smalltarget0[index] != NULL)
+ {
+ (*d3dintf->surface.release)(smalltarget0[index]);
+ smalltarget0[index] = NULL;
+ }
+ if (last_texture[index] != NULL)
+ {
+ (*d3dintf->texture.release)(last_texture[index]);
+ last_texture[index] = NULL;
+ }
+ if (last_target[index] != NULL)
+ {
+ (*d3dintf->surface.release)(last_target[index]);
+ last_target[index] = NULL;
+ }
+ }
+
+ if (avi_copy_texture != NULL)
+ {
+ (*d3dintf->texture.release)(avi_copy_texture);
+ avi_copy_texture = NULL;
+ }
+
+ if (avi_copy_surface != NULL)
+ {
+ (*d3dintf->surface.release)(avi_copy_surface);
+ avi_copy_surface = NULL;
+ }
+
+ if (avi_final_texture != NULL)
+ {
+ (*d3dintf->texture.release)(avi_final_texture);
+ avi_final_texture = NULL;
+ }
+
+ if (avi_final_target != NULL)
+ {
+ (*d3dintf->surface.release)(avi_final_target);
+ avi_final_target = NULL;
+ }
+
+ if (options != NULL)
+ {
+ global_free(options);
+ }
+
+ registered_targets = 0;
+
+ if (shadow_texture != NULL)
+ {
+ global_free(shadow_texture);
+ shadow_texture = NULL;
+ }
+
+ if (shadow_bitmap != NULL)
+ {
+ global_free(shadow_bitmap);
+ shadow_bitmap = NULL;
+ }
+}
+
+
+/*-------------------------------------------------
+ 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 global slider accessors
+//============================================================
+
+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(&(((hlsl_options*)arg)->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)
+{
+ hlsl_options *options = (hlsl_options*)arg;
+ if (newval != SLIDER_NOCHANGE) options->shadow_mask_count_x = newval;
+ if (string != NULL) string->printf("%d", options->shadow_mask_count_x);
+ return options->shadow_mask_count_x;
+}
+
+static INT32 slider_shadow_mask_y_count(running_machine &machine, void *arg, astring *string, INT32 newval)
+{
+ hlsl_options *options = (hlsl_options*)arg;
+ if (newval != SLIDER_NOCHANGE) options->shadow_mask_count_y = newval;
+ if (string != NULL) string->printf("%d", options->shadow_mask_count_y);
+ return options->shadow_mask_count_y;
+}
+
+static INT32 slider_shadow_mask_usize(running_machine &machine, void *arg, astring *string, INT32 newval)
+{
+ return slider_set(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->curvature), 0.01f, "%2.2f", string, newval);
+}
+
+static INT32 slider_pincushion(running_machine &machine, void *arg, astring *string, INT32 newval)
+{
+ return slider_set(&(((hlsl_options*)arg)->pincushion), 0.01f, "%2.2f", string, newval);
+}
+
+static INT32 slider_scanline_alpha(running_machine &machine, void *arg, astring *string, INT32 newval)
+{
+ return slider_set(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->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(&(((hlsl_options*)arg)->saturation), 0.01f, "%2.2f", string, newval);
+}
+
+//============================================================
+// init_slider_list
+//============================================================
+
+slider_state *hlsl_info::init_slider_list()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ {
+ g_slider_list = NULL;
+ return NULL;
+ }
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ slider_state *listhead = NULL;
+ slider_state **tailptr = &listhead;
+ astring string;
+
+ *tailptr = slider_alloc(window->machine(), "Shadow Mask Darkness", 0, 0, 100, 1, slider_shadow_mask_alpha, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Shadow Mask X Count", 1, 640, 1024, 1, slider_shadow_mask_x_count, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Shadow Mask Y Count", 1, 480, 1024, 1, slider_shadow_mask_y_count, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Shadow Mask Pixel Count X", 1, 3, 32, 1, slider_shadow_mask_usize, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Shadow Mask Pixel Count Y", 1, 3, 32, 1, slider_shadow_mask_vsize, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Screen Curvature", 0, 0, 100, 1, slider_curvature, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Image Pincushion", 0, 0, 100, 1, slider_pincushion, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Scanline Darkness", 0, 0, 100, 1, slider_scanline_alpha, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Scanline Screen Height", 1, 20, 80, 1, slider_scanline_scale, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Scanline Indiv. Height", 1, 10, 80, 1, slider_scanline_height, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Scanline Brightness", 0, 20, 40, 1, slider_scanline_bright_scale, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Scanline Brightness Overdrive", 0, 12, 20, 1, slider_scanline_bright_offset, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Scanline Jitter", 0, 0, 40, 1, slider_scanline_offset, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Defocus X", 0, 0, 64, 1, slider_defocus_x, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Defocus Y", 0, 0, 64, 1, slider_defocus_y, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Position Offset X", -1500, 0, 1500, 1, slider_red_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Position Offset Y", -1500, 0, 1500, 1, slider_red_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Position Offset X", -1500, 0, 1500, 1, slider_green_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Position Offset Y", -1500, 0, 1500, 1, slider_green_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Position Offset X", -1500, 0, 1500, 1, slider_blue_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Position Offset Y", -1500, 0, 1500, 1, slider_blue_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Convergence X", -1500, 0, 1500, 1, slider_red_radial_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Convergence Y", -1500, 0, 1500, 1, slider_red_radial_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Convergence X", -1500, 0, 1500, 1, slider_green_radial_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Convergence Y", -1500, 0, 1500, 1, slider_green_radial_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Convergence X", -1500, 0, 1500, 1, slider_blue_radial_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Convergence Y", -1500, 0, 1500, 1, slider_blue_radial_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Output from Red Input", -400, 0, 400, 5, slider_red_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Output from Green Input", -400, 0, 400, 5, slider_red_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Output from Blue Input", -400, 0, 400, 5, slider_red_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Output from Red Input", -400, 0, 400, 5, slider_green_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Output from Green Input", -400, 0, 400, 5, slider_green_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Output from Blue Input", -400, 0, 400, 5, slider_green_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Output from Red Input", -400, 0, 400, 5, slider_blue_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Output from Green Input", -400, 0, 400, 5, slider_blue_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Output from Blue Input", -400, 0, 400, 5, slider_blue_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red DC Offset", -100, 0, 100, 1, slider_red_offset, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green DC Offset", -100, 0, 100, 1, slider_green_offset, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue DC Offset", -100, 0, 100, 1, slider_blue_offset, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Scale", -200, 100, 200, 1, slider_red_scale, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Scale", -200, 100, 200, 1, slider_green_scale, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Scale", -200, 100, 200, 1, slider_blue_scale, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Power", -80, 20, 80, 1, slider_red_power, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Power", -80, 20, 80, 1, slider_green_power, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Power", -80, 20, 80, 1, slider_blue_power, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Floor", 0, 0, 100, 1, slider_red_floor, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Floor", 0, 0, 100, 1, slider_green_floor, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Floor", 0, 0, 100, 1, slider_blue_floor, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Red Phosphor Life", 0, 0, 100, 1, slider_red_phosphor_life, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Green Phosphor Life", 0, 0, 100, 1, slider_green_phosphor_life, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(window->machine(), "Blue Phosphor Life", 0, 0, 100, 1, slider_blue_phosphor_life, (void*)d3d); tailptr = &(*tailptr)->next;
+ *tailptr = slider_alloc(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*)g_slider_list;
+}
+
+
+
+// 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);
+}
diff --git a/src/osd/windows/d3dhlsl.h b/src/osd/windows/d3dhlsl.h
new file mode 100644
index 00000000000..72ae0de1086
--- /dev/null
+++ b/src/osd/windows/d3dhlsl.h
@@ -0,0 +1,221 @@
+//============================================================
+//
+// drawd3d.c - Win32 Direct3D HLSL-specific header
+//
+//============================================================
+//
+// Copyright Aaron Giles
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or
+// without modification, are permitted provided that the
+// following conditions are met:
+//
+// * Redistributions of source code must retain the above
+// copyright notice, this list of conditions and the
+// following disclaimer.
+// * Redistributions in binary form must reproduce the
+// above copyright notice, this list of conditions and
+// the following disclaimer in the documentation and/or
+// other materials provided with the distribution.
+// * Neither the name 'MAME' nor the names of its
+// contributors may be used to endorse or promote
+// products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGE (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//============================================================
+
+#ifndef __WIN_D3DHLSL__
+#define __WIN_D3DHLSL__
+
+
+#include "aviio.h"
+
+
+//============================================================
+// TYPE DEFINITIONS
+//============================================================
+
+/* hlsl_options is the information about runtime-mutable Direct3D HLSL options */
+/* in the future this will be moved into an OSD/emu shared buffer */
+typedef struct _hlsl_options hlsl_options;
+struct _hlsl_options
+{
+ float shadow_mask_alpha;
+ int shadow_mask_count_x;
+ int shadow_mask_count_y;
+ float shadow_mask_u_size;
+ float shadow_mask_v_size;
+ float curvature;
+ float pincushion;
+ float scanline_alpha;
+ float scanline_scale;
+ float scanline_height;
+ float scanline_bright_scale;
+ float scanline_bright_offset;
+ float scanline_offset;
+ float defocus_x;
+ float defocus_y;
+ float red_converge_x;
+ float red_converge_y;
+ float green_converge_x;
+ float green_converge_y;
+ float blue_converge_x;
+ float blue_converge_y;
+ float red_radial_converge_x;
+ float red_radial_converge_y;
+ float green_radial_converge_x;
+ float green_radial_converge_y;
+ float blue_radial_converge_x;
+ float blue_radial_converge_y;
+ float red_from_red;
+ float red_from_green;
+ float red_from_blue;
+ float green_from_red;
+ float green_from_green;
+ float green_from_blue;
+ float blue_from_red;
+ float blue_from_green;
+ float blue_from_blue;
+ float red_offset;
+ float green_offset;
+ float blue_offset;
+ float red_scale;
+ float green_scale;
+ float blue_scale;
+ float red_power;
+ float green_power;
+ float blue_power;
+ float red_floor;
+ float green_floor;
+ float blue_floor;
+ float red_phosphor_life;
+ float green_phosphor_life;
+ float blue_phosphor_life;
+ float saturation;
+};
+
+class hlsl_info
+{
+public:
+ // construction/destruction
+ hlsl_info();
+ ~hlsl_info();
+
+ void init(d3d *d3dintf, win_window_info *window);
+ void init_fsfx_quad(void *vertbuf);
+
+ bool enabled() { return master_enable; }
+
+ void begin();
+ void init_effect_info(d3d_poly_info *poly);
+ void render_quad(d3d_poly_info *poly, int vertnum);
+ void end();
+
+ int register_texture(d3d_texture_info *texture);
+ int register_prescaled_texture(d3d_texture_info *texture, int scwidth, int scheight);
+
+ void window_save();
+ void window_record();
+ bool recording() { return avi_output_file != NULL; }
+
+ void avi_update_snap(d3d_surface *surface);
+ void render_snapshot(d3d_surface *surface);
+ void record_texture();
+
+ void frame_complete();
+
+ void set_texture(d3d_texture_info *texture);
+
+ int create_resources();
+ void delete_resources();
+
+ // slider-related functions
+ slider_state *init_slider_list();
+
+private:
+ void end_avi_recording();
+ void begin_avi_recording(const char *name);
+
+ bool screen_encountered[9]; // whether a given screen was encountered this frame
+
+ d3d * d3dintf; // D3D interface
+ win_window_info * window; // D3D window info
+
+ bool master_enable; // overall enable flag
+ bool yiq_enable; // YIQ-convolution flag
+ int prescale_size; // prescale size
+ int preset; // preset, if relevant
+ bitmap_t * shadow_bitmap; // shadow mask bitmap for post-processing shader
+ d3d_texture_info * shadow_texture; // shadow mask texture for post-processing shader
+ int registered_targets; // number of registered HLSL targets (i.e., screens)
+ hlsl_options * options; // current uniform state
+ avi_file * avi_output_file; // AVI file
+ bitmap_t * avi_snap; // AVI snapshot
+ int avi_frame; // AVI frame
+ attotime avi_frame_period; // AVI frame period
+ attotime avi_next_frame_time; // AVI next frame time
+ d3d_surface * avi_copy_surface; // AVI destination surface in system memory
+ d3d_texture * avi_copy_texture; // AVI destination texture in system memory
+ d3d_surface * avi_final_target; // AVI upscaled surface
+ d3d_texture * avi_final_texture; // AVI upscaled texture
+ bool render_snap; // whether or not to take HLSL post-render snapshot
+ bool snap_rendered; // whether we just rendered our HLSL post-render shot or not
+ d3d_surface * snap_copy_target; // snapshot destination surface in system memory
+ d3d_texture * snap_copy_texture; // snapshot destination surface in system memory
+ d3d_surface * snap_target; // snapshot upscaled surface
+ d3d_texture * snap_texture; // snapshot upscaled texture
+ int snap_width; // snapshot width
+ int snap_height; // snapshot height
+
+ // HLSL effects
+ d3d_surface * backbuffer; // pointer to our device's backbuffer
+ d3d_effect * curr_effect; // pointer to the currently active effect object
+ d3d_effect * effect; // pointer to the current primary-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
+
+ // render targets
+ int target_use_count[9]; // Whether or not a target has been used yet
+ d3d_texture_info * target_in_use[9]; // Target texture that is currently in use
+ d3d_surface * last_target[9]; // Render target surface pointer for each screen's previous frame
+ d3d_texture * last_texture[9]; // Render target texture pointer for each screen's previous frame
+ d3d_surface * prescaletarget0[9]; // Render target surface pointer (prescale, if necessary)
+ d3d_surface * target0[9]; // Render target surface pointer (pass 0, if necessary)
+ d3d_surface * target1[9]; // Render target surface pointer (pass 1, if necessary)
+ d3d_surface * target2[9]; // Render target surface pointer (pass 2, if necessary)
+ d3d_surface * target3[9]; // Render target surface pointer (pass 3, if necessary)
+ d3d_surface * target4[9]; // Render target surface pointer (pass 4, if necessary)
+ d3d_surface * smalltarget0[9]; // Render target surface pointer (small pass 0, if necessary)
+ d3d_texture * prescaletexture0[9]; // Render target surface pointer (prescale, if necessary)
+ d3d_texture * texture0[9]; // Render target texture pointer (pass 0, if necessary)
+ d3d_texture * texture1[9]; // Render target texture pointer (pass 1, if necessary)
+ d3d_texture * texture2[9]; // Render target texture pointer (pass 2, if necessary)
+ d3d_texture * texture3[9]; // Render target texture pointer (pass 3, if necessary)
+ d3d_texture * texture4[9]; // Render target texture pointer (pass 4, if necessary)
+ d3d_texture * smalltexture0[9]; // Render target texture pointer (small pass 0, if necessary)
+};
+
+#endif
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);
-}
diff --git a/src/osd/windows/drawd3d.h b/src/osd/windows/drawd3d.h
new file mode 100644
index 00000000000..109a72eb1a7
--- /dev/null
+++ b/src/osd/windows/drawd3d.h
@@ -0,0 +1,127 @@
+//============================================================
+//
+// drawd3d.h - Win32 Direct3D header
+//
+//============================================================
+//
+// Copyright Aaron Giles
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or
+// without modification, are permitted provided that the
+// following conditions are met:
+//
+// * Redistributions of source code must retain the above
+// copyright notice, this list of conditions and the
+// following disclaimer.
+// * Redistributions in binary form must reproduce the
+// above copyright notice, this list of conditions and
+// the following disclaimer in the documentation and/or
+// other materials provided with the distribution.
+// * Neither the name 'MAME' nor the names of its
+// contributors may be used to endorse or promote
+// products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGE (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//============================================================
+
+#ifndef __WIN_DRAWD3D__
+#define __WIN_DRAWD3D__
+
+
+#include "d3dhlsl.h"
+
+
+//============================================================
+// CONSTANTS
+//============================================================
+
+#define VERTEX_BASE_FORMAT (D3DFVF_DIFFUSE | D3DFVF_TEX1)
+#define VERTEX_BUFFER_SIZE (2048*4+4)
+
+
+
+//============================================================
+// TYPE DEFINITIONS
+//============================================================
+
+/* 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_poly_info poly[VERTEX_BUFFER_SIZE/3]; // array to hold polygons as they are created
+ int numpolys; // number of accumulated polygons
+
+ d3d_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
+
+ d3d_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
+ d3d_texture_info * vector_texture; // experimental: texture for vectors
+
+ bitmap_t * default_bitmap; // experimental: default bitmap
+ d3d_texture_info * default_texture; // experimental: default texture
+
+ void * hlsl_buf; // HLSL vertex data
+ hlsl_info * hlsl; // HLSL interface
+};
+
+
+
+//============================================================
+// PROTOTYPES
+//============================================================
+
+d3d_texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsource, UINT32 flags);
+
+#endif
diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak
index d68877fa9d8..2a22e242c8f 100644
--- a/src/osd/windows/windows.mak
+++ b/src/osd/windows/windows.mak
@@ -286,6 +286,7 @@ OSDCOREOBJS = \
OSDOBJS = \
$(WINOBJ)/d3d9intf.o \
$(WINOBJ)/drawd3d.o \
+ $(WINOBJ)/d3dhlsl.o \
$(WINOBJ)/drawdd.o \
$(WINOBJ)/drawgdi.o \
$(WINOBJ)/drawnone.o \