RingRacers/src/hwr2/software_screen_renderer.hpp
Eidolon dae2e8ba17 rhi: Remove GraphicsContext
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.
2024-10-30 09:08:04 -05:00

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_