mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-03 22:52:50 +00:00
I've come to the conclusion that some aspects of RHI are overengineered to suit a future where we would theoretically support Vulkan with minimal implementation effort. In an effort of architectural astronaut engineering this has had the consequence of making much of the code interacting with RHI significantly more complex. The GraphicsContext was originally an opaque object to wrap and contextualize operations that would eventually be inserted into a Vulkan CommandBuffer for dispatch. In practice, for the GL backend, this does nothing but introduce another pointer to pass around across all RHI code, when it had already been previously accepted that the idea of recording multiple GraphicsContexts at the same time was infeasible. Thus, I'm choosing to excise GraphicsContext entirely. This doesn't do much except remove passing around the context object. This is one of many changes I would like to make that would simplify RHI-related code and defer the complexity to the hypothetical future. Vulkan can come at a later date, and we can solve the problems of Vulkan then. Right now, I am actually more concerned for supporting a d3d9 renderer to shore up that Intel 945GM laptop GPU support gap we currently have.
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
// DR. ROBOTNIK'S RING RACERS
|
|
//-----------------------------------------------------------------------------
|
|
// Copyright (C) 2024 by Ronald "Eidolon" Kinard
|
|
// Copyright (C) 2024 by Kart Krew
|
|
//
|
|
// This program is free software distributed under the
|
|
// terms of the GNU General Public License, version 2.
|
|
// See the 'LICENSE' file for more details.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#ifndef __SRB2_HWR2_SOFTWARE_SCREEN_RENDERER_HPP_
|
|
#define __SRB2_HWR2_SOFTWARE_SCREEN_RENDERER_HPP_
|
|
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
#include "../rhi/rhi.hpp"
|
|
|
|
namespace srb2::hwr2
|
|
{
|
|
|
|
/// @brief Renders software player views in prepass and uploads the result to a texture in transfer.
|
|
class SoftwareScreenRenderer final
|
|
{
|
|
rhi::Handle<rhi::Texture> screen_texture_;
|
|
uint32_t width_ = 0;
|
|
uint32_t height_ = 0;
|
|
|
|
// Used to ensure the row spans are aligned on the unpack boundary for weird resolutions
|
|
// Any resolution with a width divisible by 4 doesn't need this, but e.g. 1366x768 needs the intermediary copy
|
|
std::vector<uint8_t> copy_buffer_;
|
|
|
|
public:
|
|
SoftwareScreenRenderer();
|
|
~SoftwareScreenRenderer();
|
|
|
|
void draw(rhi::Rhi& rhi);
|
|
|
|
rhi::Handle<rhi::Texture> screen() const { return screen_texture_; }
|
|
};
|
|
|
|
} // namespace srb2::hwr2
|
|
|
|
#endif // __SRB2_HWR2_SOFTWARE_SCREEN_RENDERER_HPP_
|