mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'rhi-improvements' into 'master'
Various RHI improvements See merge request KartKrew/Kart!1085
This commit is contained in:
commit
44b4971232
14 changed files with 210 additions and 183 deletions
|
|
@ -235,6 +235,7 @@ target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC -DUSE_STUN)
|
|||
target_sources(SRB2SDL2 PRIVATE discord.c stun.c)
|
||||
|
||||
target_link_libraries(SRB2SDL2 PRIVATE tcbrindle::span)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE glm)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE stb_rect_pack)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE stb_vorbis)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE xmp-lite::xmp-lite)
|
||||
|
|
|
|||
|
|
@ -1955,9 +1955,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
|
|||
{
|
||||
I_OsPolling();
|
||||
|
||||
I_NewTwodeeFrame();
|
||||
I_NewImguiFrame();
|
||||
|
||||
// Needs to be updated here for M_DrawEggaChannel
|
||||
renderdeltatics = FRACUNIT;
|
||||
rendertimefrac = FRACUNIT;
|
||||
|
|
@ -2025,6 +2022,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
|
|||
#endif
|
||||
}
|
||||
I_UpdateNoVsync(); // page flip or blit buffer
|
||||
I_NewTwodeeFrame();
|
||||
#ifdef HWRENDER
|
||||
if (moviemode && rendermode == render_opengl)
|
||||
M_LegacySaveFrame();
|
||||
|
|
|
|||
|
|
@ -871,7 +871,6 @@ void D_SRB2Loop(void)
|
|||
if (rendermode != render_none)
|
||||
{
|
||||
I_NewTwodeeFrame();
|
||||
I_NewImguiFrame();
|
||||
}
|
||||
|
||||
if (realtics > 0 || singletics)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <optional>
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <tcb/span.hpp>
|
||||
|
||||
#include "../cxxutil.hpp"
|
||||
|
|
@ -122,13 +123,13 @@ void BlitRectPass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
|
|||
{
|
||||
if (quad_vbo_needs_upload_ && quad_vbo_)
|
||||
{
|
||||
rhi.update_buffer_contents(ctx, quad_vbo_, 0, tcb::as_bytes(tcb::span(kVerts)));
|
||||
rhi.update_buffer(ctx, quad_vbo_, 0, tcb::as_bytes(tcb::span(kVerts)));
|
||||
quad_vbo_needs_upload_ = false;
|
||||
}
|
||||
|
||||
if (quad_ibo_needs_upload_ && quad_ibo_)
|
||||
{
|
||||
rhi.update_buffer_contents(ctx, quad_ibo_, 0, tcb::as_bytes(tcb::span(kIndices)));
|
||||
rhi.update_buffer(ctx, quad_ibo_, 0, tcb::as_bytes(tcb::span(kIndices)));
|
||||
quad_ibo_needs_upload_ = false;
|
||||
}
|
||||
|
||||
|
|
@ -143,23 +144,25 @@ void BlitRectPass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
|
|||
|
||||
std::array<rhi::UniformVariant, 1> g1_uniforms = {{
|
||||
// Projection
|
||||
std::array<std::array<float, 4>, 4> {
|
||||
{{taller ? 1.f : 1.f / output_aspect, 0.f, 0.f, 0.f},
|
||||
{0.f, taller ? -1.f / (1.f / output_aspect) : -1.f, 0.f, 0.f},
|
||||
{0.f, 0.f, 1.f, 0.f},
|
||||
{0.f, 0.f, 0.f, 1.f}}},
|
||||
glm::scale(
|
||||
glm::identity<glm::mat4>(),
|
||||
glm::vec3(taller ? 1.f : 1.f / output_aspect, taller ? -1.f / (1.f / output_aspect) : -1.f, 1.f)
|
||||
)
|
||||
}};
|
||||
|
||||
std::array<rhi::UniformVariant, 2> g2_uniforms = {
|
||||
{// ModelView
|
||||
std::array<std::array<float, 4>, 4> {
|
||||
{{taller ? 2.f : 2.f * aspect, 0.f, 0.f, 0.f},
|
||||
{0.f, taller ? 2.f * (1.f / aspect) : 2.f, 0.f, 0.f},
|
||||
{0.f, 0.f, 1.f, 0.f},
|
||||
{0.f, 0.f, 0.f, 1.f}}},
|
||||
// Texcoord0 Transform
|
||||
std::array<std::array<float, 3>, 3> {
|
||||
{{1.f, 0.f, 0.f}, {0.f, output_flip_ ? -1.f : 1.f, 0.f}, {0.f, 0.f, 1.f}}}}};
|
||||
// ModelView
|
||||
glm::scale(
|
||||
glm::identity<glm::mat4>(),
|
||||
glm::vec3(taller ? 2.f : 2.f * aspect, taller ? 2.f * (1.f / aspect) : 2.f, 1.f)
|
||||
),
|
||||
// Texcoord0 Transform
|
||||
glm::mat3(
|
||||
glm::vec3(1.f, 0.f, 0.f),
|
||||
glm::vec3(0.f, output_flip_ ? -1.f : 1.f, 0.f),
|
||||
glm::vec3(0.f, 0.f, 1.f)
|
||||
)
|
||||
};
|
||||
|
||||
uniform_sets_[0] = rhi.create_uniform_set(ctx, {g1_uniforms});
|
||||
uniform_sets_[1] = rhi.create_uniform_set(ctx, {g2_uniforms});
|
||||
|
|
@ -178,7 +181,7 @@ void BlitRectPass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
|
|||
}
|
||||
}
|
||||
|
||||
static constexpr const rhi::Color kClearColor = {0, 0, 0, 1};
|
||||
static constexpr const glm::vec4 kClearColor = {0, 0, 0, 1};
|
||||
|
||||
void BlitRectPass::graphics(Rhi& rhi, Handle<GraphicsContext> ctx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -156,26 +156,36 @@ void ImguiPass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
|
|||
}
|
||||
|
||||
tcb::span<ImDrawVert> vert_span = tcb::span(im_list->VtxBuffer.Data, im_list->VtxBuffer.size());
|
||||
rhi.update_buffer_contents(ctx, vbo, 0, tcb::as_bytes(vert_span));
|
||||
rhi.update_buffer(ctx, vbo, 0, tcb::as_bytes(vert_span));
|
||||
|
||||
tcb::span<ImDrawIdx> index_span = tcb::span(im_list->IdxBuffer.Data, im_list->IdxBuffer.size());
|
||||
rhi.update_buffer_contents(ctx, ibo, 0, tcb::as_bytes(index_span));
|
||||
rhi.update_buffer(ctx, ibo, 0, tcb::as_bytes(index_span));
|
||||
|
||||
// Uniform sets
|
||||
std::array<UniformVariant, 1> g1_uniforms = {{
|
||||
std::array<UniformVariant, 1> g1_uniforms = {
|
||||
// Projection
|
||||
std::array<std::array<float, 4>, 4> {
|
||||
{{2.f / vid.realwidth, 0.f, 0.f, 0.f},
|
||||
{0.f, 2.f / vid.realheight, 0.f, 0.f},
|
||||
{0.f, 0.f, 1.f, 0.f},
|
||||
{-1.f, 1.f, 0.f, 1.f}}},
|
||||
}};
|
||||
glm::mat4(
|
||||
glm::vec4(2.f / vid.realwidth, 0.f, 0.f, 0.f),
|
||||
glm::vec4(0.f, 2.f / vid.realheight, 0.f, 0.f),
|
||||
glm::vec4(0.f, 0.f, 1.f, 0.f),
|
||||
glm::vec4(-1.f, 1.f, 0.f, 1.f)
|
||||
)
|
||||
};
|
||||
std::array<UniformVariant, 2> g2_uniforms = {
|
||||
{// ModelView
|
||||
std::array<std::array<float, 4>, 4> {
|
||||
{{1.f, 0.f, 0.f, 0.f}, {0.f, -1.f, 0.f, 0.f}, {0.f, 0.f, 1.f, 0.f}, {0.f, 0, 0.f, 1.f}}},
|
||||
// Texcoord0 Transform
|
||||
std::array<std::array<float, 3>, 3> {{{1.f, 0.f, 0.f}, {0.f, 1.f, 0.f}, {0.f, 0.f, 1.f}}}}};
|
||||
// ModelView
|
||||
glm::mat4(
|
||||
glm::vec4(1.f, 0.f, 0.f, 0.f),
|
||||
glm::vec4(0.f, -1.f, 0.f, 0.f),
|
||||
glm::vec4(0.f, 0.f, 1.f, 0.f),
|
||||
glm::vec4(0.f, 0, 0.f, 1.f)
|
||||
),
|
||||
// Texcoord0 Transform
|
||||
glm::mat3(
|
||||
glm::vec3(1.f, 0.f, 0.f),
|
||||
glm::vec3(0.f, 1.f, 0.f),
|
||||
glm::vec3(0.f, 0.f, 1.f)
|
||||
)
|
||||
};
|
||||
Handle<UniformSet> us_1 = rhi.create_uniform_set(ctx, {g1_uniforms});
|
||||
Handle<UniformSet> us_2 = rhi.create_uniform_set(ctx, {g2_uniforms});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <string>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <tcb/span.hpp>
|
||||
|
||||
#include "../f_finale.h"
|
||||
|
|
@ -174,13 +175,13 @@ void PostprocessWipePass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
|
|||
|
||||
if (upload_vbo_)
|
||||
{
|
||||
rhi.update_buffer_contents(ctx, vbo_, 0, tcb::as_bytes(tcb::span(kPostprocessVerts)));
|
||||
rhi.update_buffer(ctx, vbo_, 0, tcb::as_bytes(tcb::span(kPostprocessVerts)));
|
||||
upload_vbo_ = false;
|
||||
}
|
||||
|
||||
if (upload_ibo_)
|
||||
{
|
||||
rhi.update_buffer_contents(ctx, ibo_, 0, tcb::as_bytes(tcb::span(kPostprocessIndices)));
|
||||
rhi.update_buffer(ctx, ibo_, 0, tcb::as_bytes(tcb::span(kPostprocessIndices)));
|
||||
upload_ibo_ = false;
|
||||
}
|
||||
|
||||
|
|
@ -188,10 +189,10 @@ void PostprocessWipePass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
|
|||
rhi.update_texture(ctx, wipe_tex_, {0, 0, mask_w_, mask_h_}, PixelFormat::kR8, data);
|
||||
|
||||
UniformVariant uniforms[] = {
|
||||
{std::array<std::array<float, 4>, 4> {
|
||||
{{2.f, 0.f, 0.f, 0.f}, {0.f, 2.f, 0.f, 0.f}, {0.f, 0.f, 1.f, 0.f}, {0.f, 0.f, 0.f, 1.f}}}},
|
||||
{static_cast<int32_t>(wipe_color_mode_)},
|
||||
{static_cast<int32_t>(wipe_swizzle_)}};
|
||||
glm::scale(glm::identity<glm::mat4>(), glm::vec3(2.f, 2.f, 1.f)),
|
||||
static_cast<int32_t>(wipe_color_mode_),
|
||||
static_cast<int32_t>(wipe_swizzle_)
|
||||
};
|
||||
us_ = rhi.create_uniform_set(ctx, {tcb::span(uniforms)});
|
||||
|
||||
VertexAttributeBufferBinding vbos[] = {{0, vbo_}};
|
||||
|
|
|
|||
|
|
@ -12,73 +12,10 @@
|
|||
#include "../i_video.h"
|
||||
#include "../v_video.h"
|
||||
|
||||
#include "../d_netcmd.h"
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
#include "../discord.h"
|
||||
#endif
|
||||
#include "../doomstat.h"
|
||||
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
|
||||
#include "../m_avrecorder.h"
|
||||
#endif
|
||||
#include "../st_stuff.h"
|
||||
#include "../s_sound.h"
|
||||
#include "../st_stuff.h"
|
||||
#include "../v_video.h"
|
||||
|
||||
using namespace srb2;
|
||||
using namespace srb2::hwr2;
|
||||
using namespace srb2::rhi;
|
||||
|
||||
static void temp_legacy_finishupdate_draws()
|
||||
{
|
||||
SCR_CalculateFPS();
|
||||
if (st_overlay)
|
||||
{
|
||||
if (cv_songcredits.value)
|
||||
HU_DrawSongCredits();
|
||||
|
||||
if (cv_ticrate.value)
|
||||
SCR_DisplayTicRate();
|
||||
|
||||
if (cv_showping.value && netgame && (consoleplayer != serverplayer || !server_lagless))
|
||||
{
|
||||
if (server_lagless)
|
||||
{
|
||||
if (consoleplayer != serverplayer)
|
||||
SCR_DisplayLocalPing();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int player = 1; player < MAXPLAYERS; player++)
|
||||
{
|
||||
if (D_IsPlayerHumanAndGaming(player))
|
||||
{
|
||||
SCR_DisplayLocalPing();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cv_mindelay.value && consoleplayer == serverplayer && Playing())
|
||||
SCR_DisplayLocalPing();
|
||||
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
|
||||
M_AVRecorder_DrawFrameRate();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (marathonmode)
|
||||
SCR_DisplayMarathonInfo();
|
||||
|
||||
// draw captions if enabled
|
||||
if (cv_closedcaptioning.value)
|
||||
SCR_ClosedCaptions();
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
if (discordRequestList != NULL)
|
||||
ST_AskToJoinEnvelope();
|
||||
#endif
|
||||
}
|
||||
|
||||
SoftwarePass::SoftwarePass() : Pass()
|
||||
{
|
||||
}
|
||||
|
|
@ -96,8 +33,6 @@ void SoftwarePass::prepass(Rhi& rhi)
|
|||
// Assume it's already been done and vid.buffer contains the composited splitscreen view.
|
||||
// In the future though, we will want to treat each player viewport separately for postprocessing.
|
||||
|
||||
temp_legacy_finishupdate_draws();
|
||||
|
||||
// Prepare RHI resources
|
||||
if (screen_texture_ && (static_cast<int32_t>(width_) != vid.width || static_cast<int32_t>(height_) != vid.height))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <unordered_set>
|
||||
|
||||
#include <stb_rect_pack.h>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include "../r_patch.h"
|
||||
#include "../v_video.h"
|
||||
|
|
@ -831,8 +832,8 @@ void TwodeePass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
|
|||
|
||||
tcb::span<const std::byte> vertex_data = tcb::as_bytes(tcb::span(orig_list.vertices));
|
||||
tcb::span<const std::byte> index_data = tcb::as_bytes(tcb::span(orig_list.indices));
|
||||
rhi.update_buffer_contents(ctx, merged_list.vbo, 0, vertex_data);
|
||||
rhi.update_buffer_contents(ctx, merged_list.ibo, 0, index_data);
|
||||
rhi.update_buffer(ctx, merged_list.vbo, 0, vertex_data);
|
||||
rhi.update_buffer(ctx, merged_list.ibo, 0, index_data);
|
||||
|
||||
// Update the binding sets for each individual merged command
|
||||
VertexAttributeBufferBinding vbos[] = {{0, merged_list.vbo}};
|
||||
|
|
@ -879,27 +880,28 @@ void TwodeePass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
|
|||
}
|
||||
|
||||
// Uniform sets
|
||||
std::array<UniformVariant, 1> g1_uniforms = {{
|
||||
std::array<UniformVariant, 1> g1_uniforms = {
|
||||
// Projection
|
||||
std::array<std::array<float, 4>, 4> {
|
||||
{{2.f / vid.width, 0.f, 0.f, 0.f},
|
||||
{0.f, -2.f / vid.height, 0.f, 0.f},
|
||||
{0.f, 0.f, 1.f, 0.f},
|
||||
{-1.f, 1.f, 0.f, 1.f}}},
|
||||
}};
|
||||
glm::mat4(
|
||||
glm::vec4(2.f / vid.width, 0.f, 0.f, 0.f),
|
||||
glm::vec4(0.f, -2.f / vid.height, 0.f, 0.f),
|
||||
glm::vec4(0.f, 0.f, 1.f, 0.f),
|
||||
glm::vec4(-1.f, 1.f, 0.f, 1.f)
|
||||
),
|
||||
};
|
||||
std::array<UniformVariant, 3> g2_uniforms = {
|
||||
{// ModelView
|
||||
std::array<std::array<float, 4>, 4> {
|
||||
{{1.f, 0.f, 0.f, 0.f}, {0.f, 1.f, 0.f, 0.f}, {0.f, 0.f, 1.f, 0.f}, {0.f, 0.f, 0.f, 1.f}}},
|
||||
// Texcoord0 Transform
|
||||
std::array<std::array<float, 3>, 3> {{{1.f, 0.f, 0.f}, {0.f, 1.f, 0.f}, {0.f, 0.f, 1.f}}},
|
||||
// Sampler 0 Is Indexed Alpha (yes, it always is)
|
||||
static_cast<int32_t>(1)}};
|
||||
// ModelView
|
||||
glm::identity<glm::mat4>(),
|
||||
// Texcoord0 Transform
|
||||
glm::identity<glm::mat3>(),
|
||||
// Sampler 0 Is Indexed Alpha (yes, it always is)
|
||||
static_cast<int32_t>(1)
|
||||
};
|
||||
us_1 = rhi.create_uniform_set(ctx, {tcb::span(g1_uniforms)});
|
||||
us_2 = rhi.create_uniform_set(ctx, {tcb::span(g2_uniforms)});
|
||||
}
|
||||
|
||||
static constexpr const rhi::Color kClearColor = {0, 0, 0, 1};
|
||||
static constexpr const glm::vec4 kClearColor = {0, 0, 0, 1};
|
||||
|
||||
void TwodeePass::graphics(Rhi& rhi, Handle<GraphicsContext> ctx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,6 +36,20 @@
|
|||
#include "sdl/ogl_sdl.h"
|
||||
#include "st_stuff.h" // kill
|
||||
|
||||
// Legacy FinishUpdate Draws
|
||||
#include "d_netcmd.h"
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
#include "discord.h"
|
||||
#endif
|
||||
#include "doomstat.h"
|
||||
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
|
||||
#include "m_avrecorder.h"
|
||||
#endif
|
||||
#include "st_stuff.h"
|
||||
#include "s_sound.h"
|
||||
#include "st_stuff.h"
|
||||
#include "v_video.h"
|
||||
|
||||
using namespace srb2;
|
||||
using namespace srb2::hwr2;
|
||||
using namespace srb2::rhi;
|
||||
|
|
@ -117,6 +131,56 @@ static void finish_legacy_ogl_update()
|
|||
}
|
||||
#endif
|
||||
|
||||
static void temp_legacy_finishupdate_draws()
|
||||
{
|
||||
SCR_CalculateFPS();
|
||||
if (st_overlay)
|
||||
{
|
||||
if (cv_songcredits.value)
|
||||
HU_DrawSongCredits();
|
||||
|
||||
if (cv_ticrate.value)
|
||||
SCR_DisplayTicRate();
|
||||
|
||||
if (cv_showping.value && netgame && (consoleplayer != serverplayer || !server_lagless))
|
||||
{
|
||||
if (server_lagless)
|
||||
{
|
||||
if (consoleplayer != serverplayer)
|
||||
SCR_DisplayLocalPing();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int player = 1; player < MAXPLAYERS; player++)
|
||||
{
|
||||
if (D_IsPlayerHumanAndGaming(player))
|
||||
{
|
||||
SCR_DisplayLocalPing();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cv_mindelay.value && consoleplayer == serverplayer && Playing())
|
||||
SCR_DisplayLocalPing();
|
||||
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
|
||||
M_AVRecorder_DrawFrameRate();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (marathonmode)
|
||||
SCR_DisplayMarathonInfo();
|
||||
|
||||
// draw captions if enabled
|
||||
if (cv_closedcaptioning.value)
|
||||
SCR_ClosedCaptions();
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
if (discordRequestList != NULL)
|
||||
ST_AskToJoinEnvelope();
|
||||
#endif
|
||||
}
|
||||
|
||||
static InternalPassData build_pass_manager()
|
||||
{
|
||||
auto framebuffer_manager = std::make_shared<FramebufferManager>();
|
||||
|
|
@ -227,6 +291,7 @@ static InternalPassData build_pass_manager()
|
|||
rhi.present();
|
||||
rhi.finish();
|
||||
framebuffer_manager->reset_post();
|
||||
I_NewImguiFrame();
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -364,6 +429,8 @@ void I_FinishUpdate(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
temp_legacy_finishupdate_draws();
|
||||
|
||||
rhi::Rhi* rhi = sys::get_rhi(sys::g_current_rhi);
|
||||
|
||||
if (rhi == nullptr)
|
||||
|
|
@ -392,6 +459,8 @@ void I_FinishUpdateWipeStartScreen(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
temp_legacy_finishupdate_draws();
|
||||
|
||||
rhi::Rhi* rhi = sys::get_rhi(sys::g_current_rhi);
|
||||
|
||||
if (rhi == nullptr)
|
||||
|
|
@ -403,6 +472,7 @@ void I_FinishUpdateWipeStartScreen(void)
|
|||
maybe_reinit_passes(rhi);
|
||||
|
||||
g_passes->wipe_capture_start_rendering->render(*rhi);
|
||||
I_NewImguiFrame();
|
||||
}
|
||||
|
||||
void I_FinishUpdateWipeEndScreen(void)
|
||||
|
|
@ -420,6 +490,8 @@ void I_FinishUpdateWipeEndScreen(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
temp_legacy_finishupdate_draws();
|
||||
|
||||
rhi::Rhi* rhi = sys::get_rhi(sys::g_current_rhi);
|
||||
|
||||
if (rhi == nullptr)
|
||||
|
|
@ -431,6 +503,7 @@ void I_FinishUpdateWipeEndScreen(void)
|
|||
maybe_reinit_passes(rhi);
|
||||
|
||||
g_passes->wipe_capture_end_rendering->render(*rhi);
|
||||
I_NewImguiFrame();
|
||||
}
|
||||
|
||||
void I_FinishUpdateWipe(void)
|
||||
|
|
@ -448,6 +521,8 @@ void I_FinishUpdateWipe(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
temp_legacy_finishupdate_draws();
|
||||
|
||||
rhi::Rhi* rhi = sys::get_rhi(sys::g_current_rhi);
|
||||
|
||||
if (rhi == nullptr)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <fmt/format.h>
|
||||
#include <glad/gl.h>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
using namespace srb2;
|
||||
using namespace rhi;
|
||||
|
|
@ -646,7 +647,7 @@ void GlCoreRhi::destroy_buffer(rhi::Handle<rhi::Buffer> handle)
|
|||
disposal_.push_back([this, name] { gl_->DeleteBuffers(1, &name); });
|
||||
}
|
||||
|
||||
void GlCoreRhi::update_buffer_contents(
|
||||
void GlCoreRhi::update_buffer(
|
||||
rhi::Handle<TransferContext> ctx,
|
||||
rhi::Handle<rhi::Buffer> handle,
|
||||
uint32_t offset,
|
||||
|
|
@ -1426,19 +1427,19 @@ void GlCoreRhi::bind_uniform_set(Handle<GraphicsContext> ctx, uint32_t slot, Han
|
|||
gl_->Uniform1f(pipeline_uniform, value);
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const std::array<float, 2>& value)
|
||||
[&](const glm::vec2& value)
|
||||
{
|
||||
gl_->Uniform2f(pipeline_uniform, value[0], value[1]);
|
||||
gl_->Uniform2f(pipeline_uniform, value.x, value.y);
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const std::array<float, 3>& value)
|
||||
[&](const glm::vec3& value)
|
||||
{
|
||||
gl_->Uniform3f(pipeline_uniform, value[0], value[1], value[2]);
|
||||
gl_->Uniform3f(pipeline_uniform, value.x, value.y, value.z);
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const std::array<float, 4>& value)
|
||||
[&](const glm::vec4& value)
|
||||
{
|
||||
gl_->Uniform4f(pipeline_uniform, value[0], value[1], value[2], value[3]);
|
||||
gl_->Uniform4f(pipeline_uniform, value.x, value.y, value.z, value.w);
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const int32_t& value)
|
||||
|
|
@ -1446,34 +1447,34 @@ void GlCoreRhi::bind_uniform_set(Handle<GraphicsContext> ctx, uint32_t slot, Han
|
|||
gl_->Uniform1i(pipeline_uniform, value);
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const std::array<int32_t, 2>& value)
|
||||
[&](const glm::ivec2& value)
|
||||
{
|
||||
gl_->Uniform2i(pipeline_uniform, value[0], value[1]);
|
||||
gl_->Uniform2i(pipeline_uniform, value.x, value.y);
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const std::array<int32_t, 3>& value)
|
||||
[&](const glm::ivec3& value)
|
||||
{
|
||||
gl_->Uniform3i(pipeline_uniform, value[0], value[1], value[2]);
|
||||
gl_->Uniform3i(pipeline_uniform, value.x, value.y, value.z);
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const std::array<int32_t, 4>& value)
|
||||
[&](const glm::ivec4& value)
|
||||
{
|
||||
gl_->Uniform4i(pipeline_uniform, value[0], value[1], value[2], value[3]);
|
||||
gl_->Uniform4i(pipeline_uniform, value.x, value.y, value.z, value.w);
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const std::array<std::array<float, 2>, 2>& value)
|
||||
[&](const glm::mat2& value)
|
||||
{
|
||||
gl_->UniformMatrix2fv(pipeline_uniform, 1, false, reinterpret_cast<const GLfloat*>(&value));
|
||||
gl_->UniformMatrix2fv(pipeline_uniform, 1, false, glm::value_ptr(value));
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const std::array<std::array<float, 3>, 3>& value)
|
||||
[&](const glm::mat3& value)
|
||||
{
|
||||
gl_->UniformMatrix3fv(pipeline_uniform, 1, false, reinterpret_cast<const GLfloat*>(&value));
|
||||
gl_->UniformMatrix3fv(pipeline_uniform, 1, false, glm::value_ptr(value));
|
||||
GL_ASSERT
|
||||
},
|
||||
[&](const std::array<std::array<float, 4>, 4>& value)
|
||||
[&](const glm::mat4& value)
|
||||
{
|
||||
gl_->UniformMatrix4fv(pipeline_uniform, 1, false, reinterpret_cast<const GLfloat*>(&value));
|
||||
gl_->UniformMatrix4fv(pipeline_uniform, 1, false, glm::value_ptr(value));
|
||||
GL_ASSERT
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public:
|
|||
virtual Handle<TransferContext> begin_transfer() override;
|
||||
virtual void end_transfer(Handle<TransferContext> handle) override;
|
||||
|
||||
virtual void update_buffer_contents(
|
||||
virtual void update_buffer(
|
||||
Handle<TransferContext> ctx,
|
||||
Handle<Buffer> buffer,
|
||||
uint32_t offset,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@
|
|||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <tcb/span.hpp>
|
||||
|
||||
#include "../core/static_vec.hpp"
|
||||
|
|
@ -209,14 +215,6 @@ enum class SamplerName
|
|||
kSampler3
|
||||
};
|
||||
|
||||
struct Color
|
||||
{
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float a;
|
||||
};
|
||||
|
||||
struct Rect
|
||||
{
|
||||
int32_t x;
|
||||
|
|
@ -391,7 +389,7 @@ struct PipelineDesc
|
|||
PrimitiveType primitive;
|
||||
CullMode cull;
|
||||
FaceWinding winding;
|
||||
Color blend_color;
|
||||
glm::vec4 blend_color;
|
||||
};
|
||||
|
||||
struct RenderPassDesc
|
||||
|
|
@ -428,50 +426,40 @@ struct RenderPassBeginInfo
|
|||
Handle<RenderPass> render_pass;
|
||||
TextureOrRenderbuffer color_attachment;
|
||||
std::optional<TextureOrRenderbuffer> depth_attachment;
|
||||
Color clear_color;
|
||||
glm::vec4 clear_color;
|
||||
};
|
||||
|
||||
using UniformVariant = std::variant<
|
||||
float,
|
||||
std::array<float, 2>,
|
||||
std::array<float, 3>,
|
||||
std::array<float, 4>,
|
||||
glm::vec2,
|
||||
glm::vec3,
|
||||
glm::vec4,
|
||||
|
||||
int32_t,
|
||||
std::array<int32_t, 2>,
|
||||
std::array<int32_t, 3>,
|
||||
std::array<int32_t, 4>,
|
||||
glm::ivec2,
|
||||
glm::ivec3,
|
||||
glm::ivec4,
|
||||
|
||||
// The indexing order of matrices is [row][column].
|
||||
|
||||
std::array<std::array<float, 2>, 2>,
|
||||
std::array<std::array<float, 3>, 3>,
|
||||
std::array<std::array<float, 4>, 4>>;
|
||||
glm::mat2,
|
||||
glm::mat3,
|
||||
glm::mat4
|
||||
>;
|
||||
|
||||
inline constexpr UniformFormat uniform_variant_format(const UniformVariant& variant)
|
||||
{
|
||||
struct Visitor
|
||||
{
|
||||
UniformFormat operator()(const float&) const noexcept { return UniformFormat::kFloat; }
|
||||
UniformFormat operator()(const std::array<float, 2>&) const noexcept { return UniformFormat::kFloat2; }
|
||||
UniformFormat operator()(const std::array<float, 3>&) const noexcept { return UniformFormat::kFloat3; }
|
||||
UniformFormat operator()(const std::array<float, 4>&) const noexcept { return UniformFormat::kFloat4; }
|
||||
UniformFormat operator()(const glm::vec2&) const noexcept { return UniformFormat::kFloat2; }
|
||||
UniformFormat operator()(const glm::vec3&) const noexcept { return UniformFormat::kFloat3; }
|
||||
UniformFormat operator()(const glm::vec4&) const noexcept { return UniformFormat::kFloat4; }
|
||||
UniformFormat operator()(const int32_t&) const noexcept { return UniformFormat::kInt; }
|
||||
UniformFormat operator()(const std::array<int32_t, 2>&) const noexcept { return UniformFormat::kInt2; }
|
||||
UniformFormat operator()(const std::array<int32_t, 3>&) const noexcept { return UniformFormat::kInt3; }
|
||||
UniformFormat operator()(const std::array<int32_t, 4>&) const noexcept { return UniformFormat::kInt4; }
|
||||
UniformFormat operator()(const std::array<std::array<float, 2>, 2>&) const noexcept
|
||||
{
|
||||
return UniformFormat::kMat2;
|
||||
}
|
||||
UniformFormat operator()(const std::array<std::array<float, 3>, 3>&) const noexcept
|
||||
{
|
||||
return UniformFormat::kMat3;
|
||||
}
|
||||
UniformFormat operator()(const std::array<std::array<float, 4>, 4>&) const noexcept
|
||||
{
|
||||
return UniformFormat::kMat4;
|
||||
}
|
||||
UniformFormat operator()(const glm::ivec2&) const noexcept { return UniformFormat::kInt2; }
|
||||
UniformFormat operator()(const glm::ivec3&) const noexcept { return UniformFormat::kInt3; }
|
||||
UniformFormat operator()(const glm::ivec4&) const noexcept { return UniformFormat::kInt4; }
|
||||
UniformFormat operator()(const glm::mat2&) const noexcept { return UniformFormat::kMat2; }
|
||||
UniformFormat operator()(const glm::mat3&) const noexcept { return UniformFormat::kMat3; }
|
||||
UniformFormat operator()(const glm::mat4&) const noexcept { return UniformFormat::kMat4; }
|
||||
};
|
||||
return std::visit(Visitor {}, variant);
|
||||
}
|
||||
|
|
@ -537,7 +525,7 @@ struct Rhi
|
|||
virtual void end_transfer(Handle<TransferContext> handle) = 0;
|
||||
|
||||
// Transfer Context functions
|
||||
virtual void update_buffer_contents(
|
||||
virtual void update_buffer(
|
||||
Handle<TransferContext> ctx,
|
||||
Handle<Buffer> buffer,
|
||||
uint32_t offset,
|
||||
|
|
|
|||
1
thirdparty/CMakeLists.txt
vendored
1
thirdparty/CMakeLists.txt
vendored
|
|
@ -17,6 +17,7 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
|
|||
include("cpm-libgme.cmake")
|
||||
endif()
|
||||
|
||||
include("cpm-glm.cmake")
|
||||
include("cpm-rapidjson.cmake")
|
||||
include("cpm-discordrpc.cmake")
|
||||
include("cpm-xmp-lite.cmake")
|
||||
|
|
|
|||
13
thirdparty/cpm-glm.cmake
vendored
Normal file
13
thirdparty/cpm-glm.cmake
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
CPMAddPackage(
|
||||
NAME glm
|
||||
VERSION 0.9.9.8
|
||||
URL "https://github.com/g-truc/glm/releases/download/0.9.9.8/glm-0.9.9.8.zip"
|
||||
EXCLUDE_FROM_ALL ON
|
||||
DOWNLOAD_ONLY ON
|
||||
)
|
||||
|
||||
if(glm_ADDED)
|
||||
add_library(glm INTERFACE)
|
||||
add_library(glm::glm ALIAS glm)
|
||||
target_include_directories(glm INTERFACE "${glm_SOURCE_DIR}")
|
||||
endif()
|
||||
Loading…
Add table
Reference in a new issue