mirror of
https://github.com/holub/mame
synced 2025-10-05 00:38:58 +03:00
HLSL "Hurricain't Keep A Good Dev Down" Bugfix Extravaganza: [Ryan Holtz, Bat
Country Entertainment] - Created two flags, -hlsl_ini_write and -hlsl_ini_read. The former enables custom HLSL INI writing explicitly, the other enables loading of the same. - Fixed disappearing aperture effect when using custom INI files. - Fixed diagonal seam on some games, for serious real this time - Fixed phosphor simulation, now works as expected
This commit is contained in:
parent
1bf5ecd874
commit
4523bfa2d0
@ -64,6 +64,14 @@ uniform float TargetHeight;
|
||||
uniform float RawWidth;
|
||||
uniform float RawHeight;
|
||||
|
||||
uniform float WidthRatio;
|
||||
uniform float HeightRatio;
|
||||
|
||||
uniform float TextureWidth;
|
||||
uniform float TextureHeight;
|
||||
|
||||
uniform float Passthrough;
|
||||
|
||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
{
|
||||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||
@ -77,8 +85,8 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
|
||||
Output.Color = Input.Color;
|
||||
|
||||
float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight);
|
||||
Output.TexCoord = Input.TexCoord + 0.5f * InvTexSize;
|
||||
float2 InvTexSize = float2(1.0f / TextureWidth, 1.0f / TextureHeight);
|
||||
Output.TexCoord = Input.TexCoord + float2(0.5f, 0.5f) * InvTexSize;
|
||||
Output.PrevCoord = Output.TexCoord;
|
||||
|
||||
return Output;
|
||||
@ -99,7 +107,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
||||
float GreenMax = max(CurrPix.g, PrevPix.g);
|
||||
float BlueMax = max(CurrPix.b, PrevPix.b);
|
||||
|
||||
return float4(RedMax, GreenMax, BlueMax, CurrPix.a);
|
||||
return lerp(float4(RedMax, GreenMax, BlueMax, CurrPix.a), CurrPix, Passthrough);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -59,7 +59,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
Output.Position.y -= 0.5f;
|
||||
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
|
||||
|
||||
Output.TexCoord = Input.TexCoord;
|
||||
Output.TexCoord = Input.TexCoord + 0.5f / float2(TargetWidth, TargetHeight);
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
@ -653,25 +653,30 @@ void hlsl_info::init_fsfx_quad(void *vertbuf)
|
||||
fsfx_vertices[1].y = 0.0f;
|
||||
fsfx_vertices[2].x = 0.0f;
|
||||
fsfx_vertices[2].y = d3d->height;
|
||||
fsfx_vertices[3].x = d3d->width + 1.5f;
|
||||
fsfx_vertices[3].y = 0.0f - 1.5f;
|
||||
fsfx_vertices[4].x = 0.0f + 1.5f;
|
||||
fsfx_vertices[4].y = d3d->height - 1.5f;
|
||||
fsfx_vertices[5].x = d3d->width + 1.5f;
|
||||
fsfx_vertices[5].y = d3d->height - 1.5f;
|
||||
fsfx_vertices[3].x = d3d->width;
|
||||
fsfx_vertices[3].y = 0.0f;
|
||||
fsfx_vertices[4].x = 0.0f;
|
||||
fsfx_vertices[4].y = d3d->height;
|
||||
fsfx_vertices[5].x = d3d->width;
|
||||
fsfx_vertices[5].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 + 1.5f / d3d->width;
|
||||
fsfx_vertices[3].v0 = 0.0f - 1.5f / d3d->height;
|
||||
fsfx_vertices[4].u0 = 0.0f + 1.5f / d3d->width;
|
||||
fsfx_vertices[4].v0 = 1.0f - 1.5f / d3d->height;
|
||||
fsfx_vertices[5].u0 = 1.0f + 1.5f / d3d->width;
|
||||
fsfx_vertices[5].v0 = 1.0f - 1.5f / d3d->height;
|
||||
|
||||
fsfx_vertices[3].u0 = 1.0f;
|
||||
fsfx_vertices[3].v0 = 0.0f;
|
||||
|
||||
fsfx_vertices[4].u0 = 0.0f;
|
||||
fsfx_vertices[4].v0 = 1.0f;
|
||||
|
||||
fsfx_vertices[5].u0 = 1.0f;
|
||||
fsfx_vertices[5].v0 = 1.0f;
|
||||
|
||||
// set the color, Z parameters to standard values
|
||||
for (int i = 0; i < 6; i++)
|
||||
@ -715,17 +720,23 @@ int hlsl_info::create_resources()
|
||||
options = (hlsl_options*)global_alloc_clear(hlsl_options);
|
||||
|
||||
options->params_dirty = true;
|
||||
strcpy(options->shadow_mask_texture, downcast<windows_options &>(window->machine().options()).screen_shadow_mask_texture()); // unsafe
|
||||
|
||||
write_ini = downcast<windows_options &>(window->machine().options()).hlsl_write_ini();
|
||||
read_ini = downcast<windows_options &>(window->machine().options()).hlsl_read_ini();
|
||||
|
||||
if(read_ini)
|
||||
{
|
||||
emu_file ini_file(downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(), OPEN_FLAG_READ | OPEN_FLAG_CREATE_PATHS);
|
||||
file_error filerr = open_next((d3d_info*)window->drawdata, ini_file, downcast<windows_options &>(window->machine().options()).hlsl_ini_name(), "ini", 0);
|
||||
|
||||
external_ini = false;
|
||||
read_ini = false;
|
||||
if (filerr == FILERR_NONE)
|
||||
{
|
||||
ini_file.seek(0, SEEK_END);
|
||||
if (ini_file.tell() >= 1000)
|
||||
{
|
||||
external_ini = true;
|
||||
read_ini = true;
|
||||
ini_file.seek(0, SEEK_SET);
|
||||
|
||||
int en = 0;
|
||||
@ -884,6 +895,7 @@ int hlsl_info::create_resources()
|
||||
sscanf(buf, "yiq_phase_count %d\n", &options->yiq_phase_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// experimental: load a PNG to use for vector rendering; it is treated
|
||||
// as a brightness map
|
||||
@ -907,7 +919,7 @@ int hlsl_info::create_resources()
|
||||
shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
|
||||
}
|
||||
|
||||
if(!external_ini)
|
||||
if(!read_ini)
|
||||
{
|
||||
prescale_force_x = winoptions.d3d_hlsl_prescale_x();
|
||||
prescale_force_y = winoptions.d3d_hlsl_prescale_y();
|
||||
@ -1140,7 +1152,7 @@ void hlsl_info::begin()
|
||||
|
||||
|
||||
//============================================================
|
||||
// hlsl_info::render_quad
|
||||
// hlsl_info::init_effect_info
|
||||
//============================================================
|
||||
|
||||
void hlsl_info::init_effect_info(d3d_poly_info *poly)
|
||||
@ -1217,10 +1229,11 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
|
||||
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;
|
||||
int targetidx = poly->texture->target_index;
|
||||
screen_encountered[targetidx] = true;
|
||||
target_in_use[targetidx] = poly->texture;
|
||||
|
||||
target_use_count[poly->texture->target_index] = 60;
|
||||
target_use_count[targetidx] = 60;
|
||||
|
||||
if(options->yiq_enable)
|
||||
{
|
||||
@ -1246,7 +1259,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
(*d3dintf->effect.set_float)(curr_effect, "ScanTime", options->yiq_scan_time);
|
||||
}
|
||||
|
||||
HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, target4[poly->texture->target_index]);
|
||||
HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, target4[targetidx]);
|
||||
|
||||
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);
|
||||
@ -1268,7 +1281,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
/* 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, "Composite", texture4[targetidx]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dfinaltex);
|
||||
if(options->params_dirty)
|
||||
{
|
||||
@ -1290,7 +1303,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
(*d3dintf->effect.set_float)(curr_effect, "ScanTime", options->yiq_scan_time);
|
||||
}
|
||||
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target3[poly->texture->target_index]);
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target3[targetidx]);
|
||||
|
||||
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);
|
||||
@ -1311,7 +1324,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
|
||||
curr_effect = color_effect;
|
||||
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture3[poly->texture->target_index]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture3[targetidx]);
|
||||
}
|
||||
|
||||
curr_effect = color_effect;
|
||||
@ -1334,7 +1347,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
(*d3dintf->effect.set_float)(curr_effect, "Saturation", options->saturation);
|
||||
}
|
||||
|
||||
HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, smalltarget0[poly->texture->target_index]);
|
||||
HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, smalltarget0[targetidx]);
|
||||
|
||||
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);
|
||||
@ -1355,7 +1368,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
|
||||
/* Pre-scaling pass */
|
||||
curr_effect = prescale_effect;
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", smalltexture0[poly->texture->target_index]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", smalltexture0[targetidx]);
|
||||
|
||||
if(options->params_dirty)
|
||||
{
|
||||
@ -1369,7 +1382,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
|
||||
(*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
|
||||
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, prescaletarget0[poly->texture->target_index]);
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, prescaletarget0[targetidx]);
|
||||
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);
|
||||
@ -1385,10 +1398,9 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
|
||||
(*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_texture)(curr_effect, "Diffuse", prescaletexture0[targetidx]);
|
||||
|
||||
if(options->params_dirty)
|
||||
{
|
||||
@ -1406,7 +1418,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
|
||||
(*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
|
||||
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target2[poly->texture->target_index]);
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target2[targetidx]);
|
||||
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);
|
||||
@ -1430,7 +1442,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
/* Defocus pass 1 */
|
||||
curr_effect = focus_effect;
|
||||
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture2[poly->texture->target_index]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture2[targetidx]);
|
||||
|
||||
(*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
|
||||
@ -1443,7 +1455,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
|
||||
(*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
|
||||
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target0[poly->texture->target_index]);
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target0[targetidx]);
|
||||
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);
|
||||
@ -1461,7 +1473,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
|
||||
/* Defocus pass 2 */
|
||||
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[poly->texture->target_index]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[targetidx]);
|
||||
|
||||
(*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
|
||||
@ -1474,7 +1486,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
|
||||
(*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
|
||||
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target1[poly->texture->target_index]);
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target1[targetidx]);
|
||||
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++)
|
||||
@ -1492,6 +1504,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
// 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.
|
||||
int num_screens = registered_targets / 2;
|
||||
curr_effect = phosphor_effect;
|
||||
|
||||
if(options->params_dirty)
|
||||
@ -1500,13 +1513,18 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
(*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_vector)(curr_effect, "Phosphor", 3, options->phosphor);
|
||||
}
|
||||
(*d3dintf->effect.set_float)(curr_effect, "TextureWidth", (float)target_width[targetidx]);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "TextureHeight", (float)target_height[targetidx]);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "Passthrough", 0.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", last_texture[poly->texture->target_index]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", focus_enable ? texture1[targetidx] : texture2[targetidx]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "LastPass", last_texture[num_screens > 0 ? (targetidx % num_screens) : targetidx]); // Avoid changing targets due to page flipping
|
||||
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target0[poly->texture->target_index]);
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, target0[targetidx]);
|
||||
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);
|
||||
@ -1527,15 +1545,11 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
/* 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", texture0[targetidx]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "LastPass", texture0[targetidx]);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "Passthrough", 1.0f);
|
||||
|
||||
if(options->params_dirty)
|
||||
{
|
||||
(*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]);
|
||||
result = (*d3dintf->device.set_render_target)(d3d->device, 0, last_target[num_screens > 0 ? (targetidx % num_screens) : targetidx]); // Avoid changing targets due to page flipping
|
||||
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);
|
||||
@ -1558,7 +1572,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
{
|
||||
curr_effect = post_effect;
|
||||
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[poly->texture->target_index]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[targetidx]);
|
||||
|
||||
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);
|
||||
@ -1581,7 +1595,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
{
|
||||
curr_effect = post_effect;
|
||||
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[poly->texture->target_index]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[targetidx]);
|
||||
|
||||
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);
|
||||
@ -1605,7 +1619,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
|
||||
/* Scanlines and shadow mask */
|
||||
curr_effect = post_effect;
|
||||
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[poly->texture->target_index]);
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", texture0[targetidx]);
|
||||
|
||||
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);
|
||||
@ -1865,12 +1879,14 @@ int hlsl_info::register_prescaled_texture(d3d_texture_info *texture, int scwidth
|
||||
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]);
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale_x, scheight * hlsl_prescale_y, 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_width[idx] = scwidth * hlsl_prescale_x;
|
||||
target_height[idx] = scheight * hlsl_prescale_y;
|
||||
target_use_count[texture->target_index] = 60;
|
||||
target_in_use[texture->target_index] = texture;
|
||||
registered_targets++;
|
||||
@ -1942,12 +1958,14 @@ int hlsl_info::register_texture(d3d_texture_info *texture)
|
||||
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]);
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale_x, texture->rawheight * hlsl_prescale_y, 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_width[idx] = texture->rawwidth * hlsl_prescale_x;
|
||||
target_height[idx] = texture->rawheight * hlsl_prescale_y;
|
||||
target_use_count[texture->target_index] = 60;
|
||||
target_in_use[texture->target_index] = texture;
|
||||
registered_targets++;
|
||||
@ -1965,6 +1983,8 @@ void hlsl_info::delete_resources()
|
||||
if (!master_enable || !d3dintf->post_fx_available)
|
||||
return;
|
||||
|
||||
if(write_ini)
|
||||
{
|
||||
emu_file file(downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
file_error filerr = open_next((d3d_info*)window->drawdata, file, downcast<windows_options &>(window->machine().options()).hlsl_ini_name(), "ini", 0);
|
||||
|
||||
@ -2017,6 +2037,7 @@ void hlsl_info::delete_resources()
|
||||
file.printf("yiq_q %f\n", options->yiq_q);
|
||||
file.printf("yiq_scan_time %f\n", options->yiq_scan_time);
|
||||
file.printf("yiq_phase_count %d\n", options->yiq_phase_count);
|
||||
}
|
||||
|
||||
if (effect != NULL)
|
||||
{
|
||||
|
@ -146,7 +146,8 @@ private:
|
||||
win_window_info * window; // D3D window info
|
||||
|
||||
bool master_enable; // overall enable flag
|
||||
bool external_ini; // external ini flag
|
||||
bool write_ini; // enable external ini saving
|
||||
bool read_ini; // enable external ini loading
|
||||
int prescale_force_x; // prescale force x
|
||||
int prescale_force_y; // prescale force y
|
||||
int prescale_size_x; // prescale size x
|
||||
@ -192,6 +193,8 @@ private:
|
||||
// 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
|
||||
int target_width[9]; // Render target width
|
||||
int target_height[9]; // Render target height
|
||||
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)
|
||||
|
@ -330,8 +330,10 @@ const options_entry windows_options::s_option_entries[] =
|
||||
// post-processing options
|
||||
{ NULL, NULL, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" },
|
||||
{ WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enable HLSL post-processing (PS3.0 required)" },
|
||||
{ WINOPTION_HLSL_INI_NAME, "%g", OPTION_STRING, "HLSL INI file path" },
|
||||
{ WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" },
|
||||
{ WINOPTION_HLSL_INI_READ, "0", OPTION_BOOLEAN, "enable HLSL INI reading" },
|
||||
{ WINOPTION_HLSL_INI_WRITE, "0", OPTION_BOOLEAN, "enable HLSL INI writing" },
|
||||
{ WINOPTION_HLSL_INI_NAME, "%g", OPTION_STRING, "HLSL INI file name for this game" },
|
||||
{ WINOPTION_HLSL_PRESCALE_X, "0", OPTION_INTEGER, "HLSL pre-scale override factor for X (0 for auto)" },
|
||||
{ WINOPTION_HLSL_PRESCALE_Y, "0", OPTION_INTEGER, "HLSL pre-scale override factor for Y (0 for auto)" },
|
||||
{ WINOPTION_HLSL_PRESET";(-1-3)", "-1", OPTION_INTEGER, "HLSL preset to use (0-3)" },
|
||||
|
@ -82,6 +82,8 @@
|
||||
#define WINOPTION_HLSL_ENABLE "hlsl_enable"
|
||||
#define WINOPTION_HLSLPATH "hlslpath"
|
||||
#define WINOPTION_HLSL_INI_NAME "hlslini"
|
||||
#define WINOPTION_HLSL_INI_WRITE "hlsl_ini_write"
|
||||
#define WINOPTION_HLSL_INI_READ "hlsl_ini_read"
|
||||
#define WINOPTION_HLSL_PRESCALE_X "hlsl_prescale_x"
|
||||
#define WINOPTION_HLSL_PRESCALE_Y "hlsl_prescale_y"
|
||||
#define WINOPTION_HLSL_PRESET "hlsl_preset"
|
||||
@ -195,6 +197,8 @@ public:
|
||||
const char *screen_post_fx_dir() const { return value(WINOPTION_HLSLPATH); }
|
||||
const char *hlsl_ini_name() const { return value(WINOPTION_HLSL_INI_NAME); }
|
||||
bool d3d_hlsl_enable() const { return bool_value(WINOPTION_HLSL_ENABLE); }
|
||||
bool hlsl_write_ini() const { return bool_value(WINOPTION_HLSL_INI_WRITE); }
|
||||
bool hlsl_read_ini() const { return bool_value(WINOPTION_HLSL_INI_READ); }
|
||||
const char *d3d_hlsl_write() const { return value(WINOPTION_HLSL_WRITE); }
|
||||
int d3d_hlsl_prescale_x() const { return int_value(WINOPTION_HLSL_PRESCALE_X); }
|
||||
int d3d_hlsl_prescale_y() const { return int_value(WINOPTION_HLSL_PRESCALE_Y); }
|
||||
|
Loading…
Reference in New Issue
Block a user