mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
fix incorrect bloom functionality in fullscreen mode, nw
This commit is contained in:
parent
1b8c5fdc29
commit
daa3ae3b10
5 changed files with 84 additions and 53 deletions
|
@ -188,17 +188,17 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||
Output.Color = Input.Color;
|
||||
float2 inversePixel = 1.0f / TargetSize;
|
||||
float2 TexCoord = Input.Position.xy * inversePixel + float2(0.5f, 0.5f) * inversePixel;
|
||||
Output.TexCoord01.xy = TexCoord;
|
||||
Output.TexCoord01.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.5f;
|
||||
Output.TexCoord23.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.25f;
|
||||
Output.TexCoord23.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.125f;
|
||||
Output.TexCoord45.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0625f;
|
||||
Output.TexCoord45.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.03125f;
|
||||
Output.TexCoord67.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.015625f;
|
||||
Output.TexCoord67.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0078125f;
|
||||
Output.TexCoord89.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.00390625f;
|
||||
Output.TexCoord89.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.001953125f;
|
||||
Output.TexCoordA = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0009765625f;
|
||||
Output.TexCoord01.xy = TexCoord - inversePixel;
|
||||
Output.TexCoord01.zw = (((TexCoord - inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.5f;
|
||||
Output.TexCoord23.xy = (((TexCoord - inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.25f;
|
||||
Output.TexCoord23.zw = (((TexCoord - inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.125f;
|
||||
Output.TexCoord45.xy = (((TexCoord - inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0625f;
|
||||
Output.TexCoord45.zw = (((TexCoord - inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.03125f;
|
||||
Output.TexCoord67.xy = (((TexCoord - inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.015625f;
|
||||
Output.TexCoord67.zw = (((TexCoord + inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0078125f;
|
||||
Output.TexCoord89.xy = (((TexCoord + inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.00390625f;
|
||||
Output.TexCoord89.zw = (((TexCoord + inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.001953125f;
|
||||
Output.TexCoordA = (((TexCoord + inversePixel) - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0009765625f;
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,10 @@ struct PS_INPUT
|
|||
// Downsample Vertex Shader
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uniform float2 ScreenSize;
|
||||
uniform float2 TargetSize;
|
||||
uniform float2 SourceSize;
|
||||
uniform float2 PrimRatio;
|
||||
uniform float BloomRescale;
|
||||
|
||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
|
@ -54,16 +56,16 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||
|
||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||
Output.Position.xy /= SourceSize;
|
||||
Output.Position.xy /= ScreenSize;
|
||||
Output.Position.y = 1.0f - Output.Position.y;
|
||||
Output.Position.xy -= 0.5f;
|
||||
Output.Position.xy *= 2.0f;
|
||||
Output.Position.xy -= float2(0.5f, 0.5f);
|
||||
Output.Position.xy *= float2(2.0f, 2.0f);
|
||||
Output.Color = Input.Color;
|
||||
float2 inversePixel = 1.0f / SourceSize;
|
||||
Output.TexCoord01.xy = Input.Position.xy * inversePixel + float2(0.5f, 0.5f) * inversePixel;
|
||||
Output.TexCoord01.zw = Input.Position.xy * inversePixel + float2(1.5f, 0.5f) * inversePixel;
|
||||
Output.TexCoord23.xy = Input.Position.xy * inversePixel + float2(0.5f, 1.5f) * inversePixel;
|
||||
Output.TexCoord23.zw = Input.Position.xy * inversePixel + float2(1.5f, 1.5f) * inversePixel;
|
||||
float2 inversePixel = 1.0f / ScreenSize;
|
||||
Output.TexCoord01.xy = Input.Position.xy / ScreenSize + float2(0.5f, 0.5f) / TargetSize;
|
||||
Output.TexCoord01.zw = Input.Position.xy / ScreenSize + float2(1.5f, 0.5f) / TargetSize;
|
||||
Output.TexCoord23.xy = Input.Position.xy / ScreenSize + float2(0.5f, 1.5f) / TargetSize;
|
||||
Output.TexCoord23.zw = Input.Position.xy / ScreenSize + float2(1.5f, 1.5f) / TargetSize;
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
|
|
@ -215,10 +215,12 @@ public:
|
|||
poly_info() { }
|
||||
|
||||
void init(D3DPRIMITIVETYPE type, UINT32 count, UINT32 numverts,
|
||||
UINT32 flags, d3d::texture_info *texture, UINT32 modmode);
|
||||
UINT32 flags, d3d::texture_info *texture, UINT32 modmode,
|
||||
float prim_width, float prim_height);
|
||||
void init(D3DPRIMITIVETYPE type, UINT32 count, UINT32 numverts,
|
||||
UINT32 flags, d3d::texture_info *texture, UINT32 modmode,
|
||||
float line_time, float line_length);
|
||||
float line_time, float line_length,
|
||||
float prim_width, float prim_height);
|
||||
|
||||
D3DPRIMITIVETYPE get_type() { return m_type; }
|
||||
UINT32 get_count() { return m_count; }
|
||||
|
@ -231,7 +233,11 @@ public:
|
|||
float get_line_time() { return m_line_time; }
|
||||
float get_line_length() { return m_line_length; }
|
||||
|
||||
float get_prim_width() { return m_prim_width; }
|
||||
float get_prim_height() { return m_prim_height; }
|
||||
|
||||
private:
|
||||
|
||||
D3DPRIMITIVETYPE m_type; // type of primitive
|
||||
UINT32 m_count; // total number of primitives
|
||||
UINT32 m_numverts; // total number of vertices
|
||||
|
@ -242,6 +248,9 @@ private:
|
|||
|
||||
float m_line_time; // used by vectors
|
||||
float m_line_length; // used by vectors
|
||||
|
||||
float m_prim_width; // used by quads
|
||||
float m_prim_height; // used by quads
|
||||
};
|
||||
|
||||
}; // d3d
|
||||
|
|
|
@ -2077,16 +2077,23 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
|||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->render_texture[2]);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "BloomRescale", options->raster_bloom_scale);
|
||||
|
||||
int bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||
float bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||
int bloom_index = 0;
|
||||
int bloom_width = d3d->get_width();
|
||||
int bloom_height = d3d->get_height();
|
||||
for(; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
|
||||
float bloom_width = rt->target_width;
|
||||
float bloom_height = rt->target_height;
|
||||
float prim_width = poly->get_prim_width();
|
||||
float prim_height = poly->get_prim_height();
|
||||
float prim_ratio[2] = { prim_width / bloom_width, prim_height / bloom_height };
|
||||
float screen_size[2] = { d3d->get_width(), d3d->get_height() };
|
||||
//float target_size[2] = { bloom_width * 0.5f, bloom_height * 0.5f };
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "ScreenSize", 2, screen_size);
|
||||
for(; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f)
|
||||
{
|
||||
float source_size[2] = { bloom_width, bloom_height };
|
||||
float target_size[2] = { bloom_width >> 1, bloom_height >> 1 };
|
||||
float target_size[2] = { bloom_width, bloom_height };
|
||||
float source_size[2] = { bloom_width * 0.5f, bloom_height * 0.5f };
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "SourceSize", 2, source_size);
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "PrimRatio", 2, prim_ratio);
|
||||
|
||||
(*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
|
||||
|
||||
|
@ -2110,8 +2117,8 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
|||
(*d3dintf->effect.end)(curr_effect);
|
||||
|
||||
bloom_index++;
|
||||
bloom_width >>= 1;
|
||||
bloom_height >>= 1;
|
||||
bloom_width *= 0.5f;
|
||||
bloom_height *= 0.5f;
|
||||
}
|
||||
|
||||
// Bloom composite pass
|
||||
|
@ -2242,16 +2249,23 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
|||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->render_texture[0]);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "BloomRescale", options->vector_bloom_scale);
|
||||
|
||||
int bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||
float bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||
int bloom_index = 0;
|
||||
int bloom_width = d3d->get_width();
|
||||
int bloom_height = d3d->get_height();
|
||||
for(; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
|
||||
float bloom_width = rt->target_width;
|
||||
float bloom_height = rt->target_height;
|
||||
float prim_width = poly->get_prim_width();
|
||||
float prim_height = poly->get_prim_height();
|
||||
float prim_ratio[2] = { prim_width / bloom_width, prim_height / bloom_height };
|
||||
float screen_size[2] = { d3d->get_width(), d3d->get_height() };
|
||||
//float target_size[2] = { bloom_width * 0.5f, bloom_height * 0.5f };
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "ScreenSize", 2, screen_size);
|
||||
for(; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f)
|
||||
{
|
||||
float source_size[2] = { bloom_width, bloom_height };
|
||||
float target_size[2] = { bloom_width >> 1, bloom_height >> 1 };
|
||||
float target_size[2] = { bloom_width, bloom_height };
|
||||
float source_size[2] = { bloom_width * 0.5f, bloom_height * 0.5f };
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "SourceSize", 2, source_size);
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "PrimRatio", 2, prim_ratio);
|
||||
|
||||
(*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
|
||||
|
||||
|
@ -2274,8 +2288,8 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
|||
(*d3dintf->effect.end)(curr_effect);
|
||||
|
||||
bloom_index++;
|
||||
bloom_width >>= 1;
|
||||
bloom_height >>= 1;
|
||||
bloom_width *= 0.5f;
|
||||
bloom_height *= 0.5f;
|
||||
}
|
||||
|
||||
// Bloom composite pass
|
||||
|
|
|
@ -1577,7 +1577,7 @@ void renderer::batch_vectors()
|
|||
|
||||
// now add a polygon entry
|
||||
m_poly[m_numpolys].init(D3DPT_TRIANGLELIST, m_line_count * (options.antialias() ? 8 : 2), vector_size * m_line_count, cached_flags,
|
||||
m_texture_manager->get_vector_texture(), D3DTOP_MODULATE, 0.0f, 1.0f);
|
||||
m_texture_manager->get_vector_texture(), D3DTOP_MODULATE, 0.0f, 1.0f, 0.0f, 0.0f);
|
||||
m_numpolys++;
|
||||
|
||||
start_index += (int)((float)line_index * period);
|
||||
|
@ -1740,7 +1740,7 @@ void renderer::draw_line(const render_primitive *prim)
|
|||
|
||||
// now add a polygon entry
|
||||
m_poly[m_numpolys].init(D3DPT_TRIANGLESTRIP, 2, 4, prim->flags, get_vector_texture(),
|
||||
D3DTOP_MODULATE, 0.0f, 1.0f);
|
||||
D3DTOP_MODULATE, 0.0f, 1.0f, 0.0f, 0.0f);
|
||||
m_numpolys++;
|
||||
}
|
||||
}
|
||||
|
@ -1774,6 +1774,8 @@ void renderer::draw_quad(const render_primitive *prim)
|
|||
vertex[2].y = prim->bounds.y1 - 0.5f;
|
||||
vertex[3].x = prim->bounds.x1 - 0.5f;
|
||||
vertex[3].y = prim->bounds.y1 - 0.5f;
|
||||
float width = prim->bounds.x1 - prim->bounds.x0;
|
||||
float height = prim->bounds.y1 - prim->bounds.y0;
|
||||
|
||||
// set the texture coordinates
|
||||
if(texture != NULL)
|
||||
|
@ -1828,21 +1830,23 @@ void renderer::draw_quad(const render_primitive *prim)
|
|||
}
|
||||
|
||||
// now add a polygon entry
|
||||
m_poly[m_numpolys].init(D3DPT_TRIANGLESTRIP, 2, 4, prim->flags, texture, modmode);
|
||||
m_poly[m_numpolys].init(D3DPT_TRIANGLESTRIP, 2, 4, prim->flags, texture, modmode, width, height);
|
||||
m_numpolys++;
|
||||
}
|
||||
|
||||
void poly_info::init(D3DPRIMITIVETYPE type, UINT32 count, UINT32 numverts,
|
||||
UINT32 flags, texture_info *texture, UINT32 modmode,
|
||||
float line_time, float line_length)
|
||||
float line_time, float line_length,
|
||||
float prim_width, float prim_height)
|
||||
{
|
||||
init(type, count, numverts, flags, texture, modmode);
|
||||
init(type, count, numverts, flags, texture, modmode, prim_width, prim_height);
|
||||
m_line_time = line_time;
|
||||
m_line_length = line_length;
|
||||
}
|
||||
|
||||
void poly_info::init(D3DPRIMITIVETYPE type, UINT32 count, UINT32 numverts,
|
||||
UINT32 flags, texture_info *texture, UINT32 modmode)
|
||||
UINT32 flags, texture_info *texture, UINT32 modmode,
|
||||
float prim_width, float prim_height)
|
||||
{
|
||||
m_type = type;
|
||||
m_count = count;
|
||||
|
@ -1850,6 +1854,8 @@ void poly_info::init(D3DPRIMITIVETYPE type, UINT32 count, UINT32 numverts,
|
|||
m_flags = flags;
|
||||
m_texture = texture;
|
||||
m_modmode = modmode;
|
||||
m_prim_width = prim_width;
|
||||
m_prim_height = prim_height;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
|
@ -2851,10 +2857,10 @@ cache_target::~cache_target()
|
|||
|
||||
bool cache_target::init(renderer *d3d, base *d3dintf, int width, int height, int prescale_x, int prescale_y)
|
||||
{
|
||||
int bloom_size = (width * prescale_x < height * prescale_y) ? width * prescale_x : height * prescale_y;
|
||||
int bloom_size = (width < height) ? width : height;
|
||||
int bloom_index = 0;
|
||||
int bloom_width = width * prescale_x;
|
||||
int bloom_height = height * prescale_y;
|
||||
int bloom_width = width;
|
||||
int bloom_height = height;
|
||||
for (; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
|
||||
{
|
||||
bloom_width >>= 1;
|
||||
|
@ -2980,15 +2986,15 @@ bool render_target::init(renderer *d3d, base *d3dintf, int width, int height, in
|
|||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(prescaletexture, 0, &prescaletarget);
|
||||
|
||||
int bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||
float bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||
int bloom_index = 0;
|
||||
int bloom_width = d3d->get_width();
|
||||
int bloom_height = d3d->get_height();
|
||||
for (; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
|
||||
float bloom_width = d3d->get_width();
|
||||
float bloom_height = d3d->get_height();
|
||||
for (; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f)
|
||||
{
|
||||
bloom_width >>= 1;
|
||||
bloom_height >>= 1;
|
||||
result = (*d3dintf->device.create_texture)(d3d->get_device(), bloom_width, bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]);
|
||||
bloom_width *= 0.5f;
|
||||
bloom_height *= 0.5f;
|
||||
result = (*d3dintf->device.create_texture)(d3d->get_device(), (int)bloom_width, (int)bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_target[bloom_index]);
|
||||
|
|
Loading…
Reference in a new issue