diff options
author | 2015-07-12 23:28:38 +0200 | |
---|---|---|
committer | 2015-07-12 23:28:38 +0200 | |
commit | 9ce28641419f62fe8f95fca1dad6563cef0d995f (patch) | |
tree | 5c374dc0d1f940f294730cd2fde5ea9e39bc499e | |
parent | 6e5f7f5d943c3cacee4de7f0bdd618ee96c83557 (diff) |
Post Pass effects for Vector rendering
- added support for post pass effects for vector rendering (does not
work properly in full screen mode, yet)
- made texture_info::compute_size_subroutine() function public static
-rw-r--r-- | hlsl/post.fx | 8 | ||||
-rw-r--r-- | src/osd/modules/render/d3d/d3dcomm.h | 3 | ||||
-rw-r--r-- | src/osd/modules/render/d3d/d3dhlsl.c | 39 | ||||
-rw-r--r-- | src/osd/modules/render/drawd3d.c | 14 |
4 files changed, 43 insertions, 21 deletions
diff --git a/hlsl/post.fx b/hlsl/post.fx index 63e3aa9f5ce..615b8a2956c 100644 --- a/hlsl/post.fx +++ b/hlsl/post.fx @@ -78,7 +78,9 @@ uniform float2 Prescale = float2(8.0f, 8.0f); uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation + uniform bool PrepareBloom = false; // disables some effects for rendering bloom textures +uniform bool PrepareVector = false; VS_OUTPUT vs_main(VS_INPUT Input) { @@ -106,7 +108,7 @@ VS_OUTPUT vs_main(VS_INPUT Input) Output.Position.xy -= 0.5f; // center Output.Position.xy *= 2.0f; // zoom - Output.TexCoord = Input.TexCoord; + Output.TexCoord = PrepareVector ? (Input.Position.xy / ScreenDims) : Input.TexCoord; Output.Color = Input.Color; @@ -377,7 +379,9 @@ float4 ps_main(PS_INPUT Input) : COLOR } // Output - float4 Output = BaseColor * Input.Color; + float4 Output = PrepareVector + ? BaseColor * (Input.Color + float4(1.0f, 1.0f, 1.0f, 0.0f)) + : BaseColor * Input.Color; Output.a = 1.0f; // Light Reflection Simulation (may not affect bloom) diff --git a/src/osd/modules/render/d3d/d3dcomm.h b/src/osd/modules/render/d3d/d3dcomm.h index 399df12ad00..8b53d18d0f1 100644 --- a/src/osd/modules/render/d3d/d3dcomm.h +++ b/src/osd/modules/render/d3d/d3dcomm.h @@ -146,10 +146,11 @@ public: vec2f & get_uvstop() { return m_stop; } vec2f & get_rawdims() { return m_rawdims; } + static void compute_size_subroutine(texture_manager* texture_manager, int texwidth, int texheight, int* p_width, int* p_height); + private: void prescale(); void compute_size(int texwidth, int texheight); - void compute_size_subroutine(int texwidth, int texheight, int* p_width, int* p_height); texture_manager * m_texture_manager; // texture manager pointer diff --git a/src/osd/modules/render/d3d/d3dhlsl.c b/src/osd/modules/render/d3d/d3dhlsl.c index ded675d2b1d..1813dcc111a 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.c +++ b/src/osd/modules/render/d3d/d3dhlsl.c @@ -1462,6 +1462,24 @@ int shaders::post_pass(render_target *rt, int source_index, poly_info *poly, int curr_effect->set_bool("RotationSwapXY", rotation_swap_xy); curr_effect->set_bool("PrepareBloom", prepare_bloom); + if (prepare_vector) + { + int source_width = d3d->get_width(); + int source_height = d3d->get_height(); + int target_width = 0; + int target_height = 0; + + texture_info::compute_size_subroutine(d3d->get_texture_manager(), source_width, source_height, &target_width, &target_height); + + // todo: fix fullscreen + float source_dims[2] = { (float)target_width, (float)source_height }; + float source_rect[2] = { 1.0f, 1.0f }; + + curr_effect->set_bool("PrepareVector", prepare_vector); + curr_effect->set_vector("SourceDims", 2, source_dims); + curr_effect->set_vector("SourceRect", 2, source_rect); + } + d3d->set_wrap(D3DTADDRESS_MIRROR); next_index = rt->next_index(next_index); @@ -1696,21 +1714,20 @@ void shaders::render_quad(poly_info *poly, int vertnum) next_index = rt->next_index(next_index); blit(rt->prescale_target[next_index], true, poly->get_type(), vertnum, poly->get_count()); - - next_index = phosphor_pass(rt, ct, next_index, poly, vertnum); - - curr_effect = default_effect; - curr_effect->update_uniforms(); - curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]); - curr_effect->set_bool("PostPass", true); - curr_effect->set_float("Brighten", 1.0f); + next_index = phosphor_pass(rt, ct, next_index, poly, vertnum); - next_index = rt->next_index(next_index); - blit(rt->native_target[next_index], true, poly->get_type(), vertnum, poly->get_count()); - + // create bloom textures + int phosphor_index = next_index; + next_index = post_pass(rt, next_index, poly, vertnum, true); next_index = downsample_pass(rt, next_index, poly, vertnum); + + // apply bloom textures + next_index = phosphor_index; + next_index = post_pass(rt, next_index, poly, vertnum, false); next_index = bloom_pass(rt, next_index, poly, vertnum); + + // render on screen next_index = screen_pass(rt, next_index, poly, vertnum); HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, backbuffer); diff --git a/src/osd/modules/render/drawd3d.c b/src/osd/modules/render/drawd3d.c index 33c0b1aff97..39fbac323eb 100644 --- a/src/osd/modules/render/drawd3d.c +++ b/src/osd/modules/render/drawd3d.c @@ -2074,13 +2074,13 @@ error: // texture_info::compute_size_subroutine //============================================================ -void texture_info::compute_size_subroutine(int texwidth, int texheight, int* p_width, int* p_height) +void texture_info::compute_size_subroutine(texture_manager* texture_manager, int texwidth, int texheight, int* p_width, int* p_height) { int finalheight = texheight; int finalwidth = texwidth; // round width/height up to nearest power of 2 if we need to - if (!(m_texture_manager->get_texture_caps() & D3DPTEXTURECAPS_NONPOW2CONDITIONAL)) + if (!(texture_manager->get_texture_caps() & D3DPTEXTURECAPS_NONPOW2CONDITIONAL)) { // first the width if (finalwidth & (finalwidth - 1)) @@ -2104,7 +2104,7 @@ void texture_info::compute_size_subroutine(int texwidth, int texheight, int* p_w } // round up to square if we need to - if (m_texture_manager->get_texture_caps() & D3DPTEXTURECAPS_SQUAREONLY) + if (texture_manager->get_texture_caps() & D3DPTEXTURECAPS_SQUAREONLY) { if (finalwidth < finalheight) finalwidth = finalheight; @@ -2113,11 +2113,11 @@ void texture_info::compute_size_subroutine(int texwidth, int texheight, int* p_w } // adjust the aspect ratio if we need to - while (finalwidth < finalheight && finalheight / finalwidth > m_texture_manager->get_max_texture_aspect()) + while (finalwidth < finalheight && finalheight / finalwidth > texture_manager->get_max_texture_aspect()) { finalwidth *= 2; } - while (finalheight < finalwidth && finalwidth / finalheight > m_texture_manager->get_max_texture_aspect()) + while (finalheight < finalwidth && finalwidth / finalheight > texture_manager->get_max_texture_aspect()) { finalheight *= 2; } @@ -2151,7 +2151,7 @@ void texture_info::compute_size(int texwidth, int texheight) finalwidth += 2 * m_xborderpix; finalheight += 2 * m_yborderpix; - compute_size_subroutine(finalwidth, finalheight, &finalwidth, &finalheight); + texture_info::compute_size_subroutine(m_texture_manager, finalwidth, finalheight, &finalwidth, &finalheight); // if we added pixels for the border, and that just barely pushed us over, take it back if (finalwidth > m_texture_manager->get_max_texture_width() || finalheight > m_texture_manager->get_max_texture_height()) @@ -2162,7 +2162,7 @@ void texture_info::compute_size(int texwidth, int texheight) m_xborderpix = 0; m_yborderpix = 0; - compute_size_subroutine(finalwidth, finalheight, &finalwidth, &finalheight); + texture_info::compute_size_subroutine(m_texture_manager, finalwidth, finalheight, &finalwidth, &finalheight); } // if we're above the max width/height, do what? |