Skip to content

Commit

Permalink
quad-views: use anti-aliasing only for focus view
Browse files Browse the repository at this point in the history
  • Loading branch information
Detegr committed Jul 20, 2024
1 parent 28c615f commit 0453f24
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ set(HEADERS
set(openRBRVR_Major 0)
set(openRBRVR_Minor 8)
set(openRBRVR_Patch 3)
set(openRBRVR_Tweak 3)
set(openRBRVR_Tweak 4)
set(openRBRVR_TweakStr "-quad-view-foveated")

configure_file(
Expand Down
29 changes: 20 additions & 9 deletions src/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,27 @@ static bool create_render_target(IDirect3DDevice9* dev, D3DMULTISAMPLE_TYPE msaa

void VRInterface::init_surfaces(IDirect3DDevice9* dev, RenderContext& ctx, uint32_t res_x_2d, uint32_t res_y_2d)
{
if (!create_render_target(dev, ctx.msaa, ctx, LeftEye, D3DFMT_X8B8G8R8, ctx.width[LeftEye], ctx.height[LeftEye]))
throw std::runtime_error("Could not create texture for left eye");
if (!create_render_target(dev, ctx.msaa, ctx, RightEye, D3DFMT_X8B8G8R8, ctx.width[RightEye], ctx.height[RightEye]))
throw std::runtime_error("Could not create texture for right eye");
const auto get_msaa_type = [&](RenderTarget tgt) {
if (!g::cfg.quad_view_rendering) return ctx.msaa;

// Use MSAA only for focus view
const auto is_focus_tgt = (tgt == FocusLeft) || (tgt == FocusRight);
return is_focus_tgt ? ctx.msaa : D3DMULTISAMPLE_NONE;
};

const auto create_vr_render_target = [&](RenderTarget tgt) {
if (!create_render_target(dev, get_msaa_type(tgt), ctx, tgt, D3DFMT_X8B8G8R8, ctx.width[tgt], ctx.height[tgt])) {
throw std::runtime_error(std::format("Could not create VR render target for view: {}", static_cast<int>(tgt)));
}
};

create_vr_render_target(LeftEye);
create_vr_render_target(RightEye);
if (g::cfg.quad_view_rendering) {
if (!create_render_target(dev, ctx.msaa, ctx, FocusLeft, D3DFMT_X8B8G8R8, ctx.width[FocusLeft], ctx.height[FocusLeft]))
throw std::runtime_error("Could not create texture for left eye");
if (!create_render_target(dev, ctx.msaa, ctx, FocusRight, D3DFMT_X8B8G8R8, ctx.width[FocusRight], ctx.height[FocusRight]))
throw std::runtime_error("Could not create texture for right eye");
create_vr_render_target(FocusLeft);
create_vr_render_target(FocusRight);
}

if (!create_render_target(dev, D3DMULTISAMPLE_NONE, ctx, GameMenu, D3DFMT_X8B8G8R8, res_x_2d, res_y_2d))
throw std::runtime_error("Could not create texture for menus");
if (!create_render_target(dev, D3DMULTISAMPLE_NONE, ctx, Overlay, D3DFMT_A8B8G8R8, res_x_2d, res_y_2d))
Expand Down Expand Up @@ -272,4 +283,4 @@ void render_menu_quad(IDirect3DDevice9* dev, VRInterface* vr, IDirect3DTexture9*
void render_companion_window_from_render_target(IDirect3DDevice9* dev, VRInterface* vr, RenderTarget tgt)
{
render_texture(dev, &g::identity_matrix, &g::identity_matrix, &g::identity_matrix, vr->get_texture(tgt), (tgt == GameMenu || tgt == Overlay) ? g::companion_window_vertex_buf_menu : g::companion_window_vertex_buf_3d);
}
}

0 comments on commit 0453f24

Please sign in to comment.