summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Westley M. Martinez <anikom15@gmail.com>2017-01-04 17:44:46 -0800
committer Westley M. Martinez <anikom15@gmail.com>2017-01-04 17:44:46 -0800
commit2b95c8e50bbfa22320ca8ddd04d3d94052a5c4ed (patch)
tree7495be650b35a2c5e2f65e0a9ed4eb81debd838e
parentfad07814a01d724c0025aca39c771f13e74cff50 (diff)
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.
-rw-r--r--hlsl/phosphor.fx9
-rw-r--r--ini/presets/raster.ini4
-rw-r--r--ini/presets/vector-mono.ini2
-rw-r--r--ini/presets/vector.ini4
-rw-r--r--src/osd/modules/render/d3d/d3dcomm.h14
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp28
-rw-r--r--src/osd/modules/render/drawd3d.cpp27
7 files changed, 45 insertions, 43 deletions
diff --git a/hlsl/phosphor.fx b/hlsl/phosphor.fx
index 2505b27e17f..e7f585a1f2f 100644
--- a/hlsl/phosphor.fx
+++ b/hlsl/phosphor.fx
@@ -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);
diff --git a/ini/presets/raster.ini b/ini/presets/raster.ini
index c566fbe15ff..6d3edf3889f 100644
--- a/ini/presets/raster.ini
+++ b/ini/presets/raster.ini
@@ -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
diff --git a/ini/presets/vector-mono.ini b/ini/presets/vector-mono.ini
index 1886785c0bd..2778bc69d7a 100644
--- a/ini/presets/vector-mono.ini
+++ b/ini/presets/vector-mono.ini
@@ -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
#
diff --git a/ini/presets/vector.ini b/ini/presets/vector.ini
index c2d41cf5cb6..7f1c887919e 100644
--- a/ini/presets/vector.ini
+++ b/ini/presets/vector.ini
@@ -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
diff --git a/src/osd/modules/render/d3d/d3dcomm.h b/src/osd/modules/render/d3d/d3dcomm.h
index 38b93adb7ac..98a720988c0 100644
--- a/src/osd/modules/render/d3d/d3dcomm.h
+++ b/src/osd/modules/render/d3d/d3dcomm.h
@@ -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
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index c41ab4f083f..17861ef3ce1 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -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;
}
diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp
index d0a1ce6c9d1..4cc547b5181 100644
--- a/src/osd/modules/render/drawd3d.cpp
+++ b/src/osd/modules/render/drawd3d.cpp
@@ -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 != nullptr)
- cache_texture->Release();
+ if (cache_texture[index] != nullptr)
+ cache_texture[index]->Release();
- if (cache_surface != nullptr)
- cache_surface->Release();
+ if (cache_surface[index] != nullptr)
+ cache_surface[index]->Release();
+ }
}
@@ -2701,13 +2708,13 @@ 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_A8R8G8B8, D3DPOOL_DEFAULT, &cache_texture, nullptr);
- if (FAILED(result))
- return false;
+ 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->GetSurfaceLevel(0, &cache_surface);
+ cache_texture[index]->GetSurfaceLevel(0, &cache_surface[index]);
+ }
auto win = d3d->assert_window();