Change cached texture format to floating point.

hlsl/phosphor.fx: Remove hacks

	ini/presets/raster.ini, ini/presets/vector-mono.ini,
ini/presets/vector.ini: Tweak presets

	src/osd/modules/render/d3d/d3dcomm.h,
src/osd/modules/render/d3d/d3dhlsl.cpp,
src/osd/modules/render/drawd3d.cpp: Change cache texture format to
floating point for precise for phosphor and ghosting shaders.
This commit is contained in:
Westley M. Martinez 2017-01-04 17:44:46 -08:00
parent fad07814a0
commit 2b95c8e50b
7 changed files with 47 additions and 45 deletions

View File

@ -101,8 +101,6 @@ uniform float3 TimeConstant = { 0.0f, 0.0f, 0.0f };
uniform float3 Beta = { 0.0f, 0.0f, 0.0f };
static const float TAU_FACTOR = 0.4342944819;
static const float GAMMA_INV_FACTOR = TAU_FACTOR / 100;
// sRGB half-step for small intensities
float THRESHOLD = 0.5f / 255.0f / 12.92f;
float4 ps_main(PS_INPUT Input) : COLOR
{
@ -137,12 +135,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
b = pow(gamma.b * DeltaTime + pow(1 / b, 1 / Beta.b),
-Beta.b);
}
// Prevent burn-in
if (DeltaTime > 0.0f) {
r = max(0.0f, r - THRESHOLD);
g = max(0.0f, g - THRESHOLD);
b = max(0.0f, b - THRESHOLD);
}
r = max(CurrPix.r, r);
g = max(CurrPix.g, g);
b = max(CurrPix.b, b);

View File

@ -38,8 +38,8 @@ scale 1.15,1.05,0.90
power 0.90,0.90,1.15
floor 0.025,0.025,0.025
phosphor_mode 2
phosphor_time 0.050,0.018,0.018
phosphor_beta 1.0,0.7,0.7
phosphor_time 0.005,0.050,0.050
phosphor_beta 1.0,1.0,1.0
#
# NTSC POST-PROCESSING OPTIONS

View File

@ -38,7 +38,7 @@ scale 1.0,1.0,1.0
power 1.0,1.0,1.0
floor 0.0,0.0,0.0
phosphor_mode 2
phosphor_time 0.05,0.05,0.05
phosphor_time 0.01,0.01,0.01
phosphor_beta 1.0,1.0,1.0
#

View File

@ -41,8 +41,8 @@ scale 1.0,1.0,1.0
power 1.0,1.0,1.0
floor 0.0,0.0,0.0
phosphor_mode 2
phosphor_time 0.050,0.018,0.018
phosphor_beta 1.0,0.7,0.7
phosphor_time 0.005,0.050,0.050
phosphor_beta 1.0,1.0,1.0
#
# NTSC POST-PROCESSING OPTIONS

View File

@ -220,7 +220,7 @@ class d3d_render_target
{
public:
// construction/destruction
d3d_render_target(): target_width(0), target_height(0), width(0), height(0), screen_index(0), bloom_count(0)
d3d_render_target(): target_width(0), target_height(0), width(0), height(0), screen_index(0), bloom_count(0), cache_index(0)
{
for (int index = 0; index < MAX_BLOOM_COUNT; index++)
{
@ -234,16 +234,16 @@ public:
source_surface[index] = nullptr;
target_texture[index] = nullptr;
target_surface[index] = nullptr;
cache_texture[index] = nullptr;
cache_surface[index] = nullptr;
}
cache_texture = nullptr;
cache_surface = nullptr;
}
~d3d_render_target();
bool init(renderer_d3d9 *d3d, int source_width, int source_height, int target_width, int target_height, int screen_index);
int next_index(int index) { return ++index > 1 ? 0 : index; }
int next_cache_index() { cache_index = ++cache_index > 1 ? 0 : cache_index; return cache_index; }
// real target dimension
int target_width;
@ -260,8 +260,8 @@ public:
IDirect3DSurface9 *source_surface[2];
IDirect3DTexture9 *source_texture[2];
IDirect3DSurface9 *cache_surface;
IDirect3DTexture9 *cache_texture;
IDirect3DSurface9 *cache_surface[2];
IDirect3DTexture9 *cache_texture[2];
IDirect3DSurface9 *bloom_surface[MAX_BLOOM_COUNT];
IDirect3DTexture9 *bloom_texture[MAX_BLOOM_COUNT];
@ -269,6 +269,8 @@ public:
float bloom_dims[MAX_BLOOM_COUNT][2];
int bloom_count;
int cache_index;
};
#endif

View File

@ -1097,20 +1097,20 @@ int shaders::phosphor_pass(d3d_render_target *rt, int source_index, poly_info *p
curr_effect = phosphor_effect;
curr_effect->update_uniforms();
curr_effect->set_texture("Diffuse", rt->target_texture[next_index]);
curr_effect->set_texture("LastPass", rt->cache_texture);
curr_effect->set_texture("LastPass", rt->cache_texture[rt->cache_index]);
curr_effect->set_bool("Passthrough", false);
curr_effect->set_float("DeltaTime", delta_time());
next_index = rt->next_index(next_index);
blit(rt->target_surface[next_index], false, D3DPT_TRIANGLELIST, 0, 2);
rt->next_cache_index();
blit(rt->cache_surface[rt->cache_index], false, D3DPT_TRIANGLELIST, 0, 2);
// Pass along our phosphor'd screen
// copy cached texture to target texture
curr_effect->update_uniforms();
curr_effect->set_texture("Diffuse", rt->target_texture[next_index]);
curr_effect->set_texture("LastPass", rt->target_texture[next_index]);
curr_effect->set_texture("Diffuse", rt->cache_texture[rt->cache_index]);
curr_effect->set_texture("LastPass", rt->cache_texture[rt->cache_index]);
curr_effect->set_bool("Passthrough", true);
blit(rt->cache_surface, false, D3DPT_TRIANGLELIST, 0, 2);
blit(rt->target_surface[next_index], false, D3DPT_TRIANGLELIST, 0, 2);
return next_index;
}
@ -1129,20 +1129,20 @@ int shaders::ghosting_pass(d3d_render_target *rt, int source_index, poly_info *p
curr_effect = ghosting_effect;
curr_effect->update_uniforms();
curr_effect->set_texture("Diffuse", rt->target_texture[next_index]);
curr_effect->set_texture("LastPass", rt->cache_texture);
curr_effect->set_texture("LastPass", rt->cache_texture[rt->cache_index]);
curr_effect->set_bool("Passthrough", false);
curr_effect->set_float("DeltaTime", delta_time());
next_index = rt->next_index(next_index);
blit(rt->target_surface[next_index], false, D3DPT_TRIANGLELIST, 0, 2);
rt->next_cache_index();
blit(rt->cache_surface[rt->cache_index], false, D3DPT_TRIANGLELIST, 0, 2);
// Pass along our ghost'd screen
// copy cached texture to target texture
curr_effect->update_uniforms();
curr_effect->set_texture("Diffuse", rt->target_texture[next_index]);
curr_effect->set_texture("LastPass", rt->target_texture[next_index]);
curr_effect->set_texture("Diffuse", rt->cache_texture[rt->cache_index]);
curr_effect->set_texture("LastPass", rt->cache_texture[rt->cache_index]);
curr_effect->set_bool("Passthrough", true);
blit(rt->cache_surface, false, D3DPT_TRIANGLELIST, 0, 2);
blit(rt->target_surface[next_index], false, D3DPT_TRIANGLELIST, 0, 2);
return next_index;
}

View File

@ -1120,6 +1120,13 @@ bool renderer_d3d9::device_verify_caps()
success = false;
}
result = d3dintf->d3dobj->CheckDeviceFormat(m_adapter, D3DDEVTYPE_HAL, m_pixformat, 0, D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F);
if (FAILED(result))
{
osd_printf_error("Direct3D Error: Your graphics card does not support the A16B16G16R16F texture format.\n");
success = false;
}
if (!success)
{
osd_printf_error("This feature or features are required to use the Direct3D renderer. Please\n");
@ -2662,13 +2669,13 @@ d3d_render_target::~d3d_render_target()
if (target_surface[index] != nullptr)
target_surface[index]->Release();
if (cache_texture[index] != nullptr)
cache_texture[index]->Release();
if (cache_surface[index] != nullptr)
cache_surface[index]->Release();
}
if (cache_texture != nullptr)
cache_texture->Release();
if (cache_surface != nullptr)
cache_surface->Release();
}
@ -2701,14 +2708,14 @@ bool d3d_render_target::init(renderer_d3d9 *d3d, int source_width, int source_he
return false;
target_texture[index]->GetSurfaceLevel(0, &target_surface[index]);
result = d3d->get_device()->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &cache_texture[index], nullptr);
if (FAILED(result))
return false;
cache_texture[index]->GetSurfaceLevel(0, &cache_surface[index]);
}
result = d3d->get_device()->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &cache_texture, nullptr);
if (FAILED(result))
return false;
cache_texture->GetSurfaceLevel(0, &cache_surface);
auto win = d3d->assert_window();
auto first_screen = win->machine().first_screen();