Merge remote-tracking branch 'origin/master' into dedi-bots

This commit is contained in:
AJ Martinez 2023-07-16 01:29:00 -07:00
commit 12bc92b392
36 changed files with 451 additions and 143 deletions

View file

@ -15,6 +15,50 @@
namespace srb2
{
template <typename T, size_t Limit>
class StaticVec;
// Silly hack to avoid GCC standard library algorithms bogus compile warnings
template <typename T, size_t Limit>
class StaticVecIter
{
T* p_;
StaticVecIter(T* p) noexcept : p_(p) {}
friend class StaticVec<T, Limit>;
friend class StaticVec<typename std::remove_const<T>::type, Limit>;
public:
using difference_type = ptrdiff_t;
using value_type = T;
using pointer = T*;
using reference = T&;
using iterator_category = std::random_access_iterator_tag;
T& operator*() const noexcept { return *p_; }
T* operator->() const noexcept { return p_; }
StaticVecIter& operator++() noexcept { p_++; return *this; }
StaticVecIter operator++(int) noexcept { StaticVecIter copy = *this; ++(*this); return copy; }
StaticVecIter& operator--() noexcept { p_--; return *this; }
StaticVecIter operator--(int) noexcept { StaticVecIter copy = *this; --(*this); return copy; }
StaticVecIter& operator+=(ptrdiff_t ofs) noexcept { p_ += ofs; return *this; }
StaticVecIter& operator-=(ptrdiff_t ofs) noexcept { p_ -= ofs; return *this; }
T& operator[](ptrdiff_t ofs) noexcept { return *(p_ + ofs); }
friend ptrdiff_t operator+(const StaticVecIter& lhs, const StaticVecIter& rhs) noexcept { return lhs.p_ + rhs.p_; }
friend ptrdiff_t operator-(const StaticVecIter& lhs, const StaticVecIter& rhs) noexcept { return lhs.p_ - rhs.p_; }
friend StaticVecIter operator+(const StaticVecIter& lhs, ptrdiff_t rhs) noexcept { return lhs.p_ + rhs; }
friend StaticVecIter operator-(const StaticVecIter& lhs, ptrdiff_t rhs) noexcept { return lhs.p_ - rhs; }
friend bool operator==(const StaticVecIter& lhs, const StaticVecIter& rhs) noexcept { return lhs.p_ == rhs.p_; }
friend bool operator!=(const StaticVecIter& lhs, const StaticVecIter& rhs) noexcept { return !(lhs.p_ == rhs.p_); }
friend bool operator>(const StaticVecIter& lhs, const StaticVecIter& rhs) noexcept { return lhs.p_ > rhs.p_; }
friend bool operator<=(const StaticVecIter& lhs, const StaticVecIter& rhs) noexcept { return !(lhs.p_ > rhs.p_); }
friend bool operator<(const StaticVecIter& lhs, const StaticVecIter& rhs) noexcept { return lhs.p_ < rhs.p_; }
friend bool operator>=(const StaticVecIter& lhs, const StaticVecIter& rhs) noexcept { return !(lhs.p_ < rhs.p_); }
};
template <typename T, size_t Limit>
class StaticVec
{
@ -138,25 +182,25 @@ public:
size_ = 0;
}
constexpr T* begin() noexcept { return &arr_[0]; }
constexpr StaticVecIter<T, Limit> begin() noexcept { return &arr_[0]; }
constexpr const T* begin() const noexcept { return cbegin(); }
constexpr StaticVecIter<const T, Limit> begin() const noexcept { return cbegin(); }
constexpr const T* cbegin() const noexcept { return &arr_[0]; }
constexpr StaticVecIter<const T, Limit> cbegin() const noexcept { return &arr_[0]; }
constexpr T* end() noexcept { return &arr_[size_]; }
constexpr StaticVecIter<T, Limit> end() noexcept { return &arr_[size_]; }
constexpr const T* end() const noexcept { return cend(); }
constexpr StaticVecIter<const T, Limit> end() const noexcept { return cend(); }
constexpr const T* cend() const noexcept { return &arr_[size_]; }
constexpr StaticVecIter<const T, Limit> cend() const noexcept { return &arr_[size_]; }
constexpr std::reverse_iterator<T*> rbegin() noexcept { return &arr_[size_]; }
constexpr std::reverse_iterator<StaticVecIter<T, Limit>> rbegin() noexcept { return &arr_[size_]; }
constexpr std::reverse_iterator<const T*> crbegin() const noexcept { return &arr_[size_]; }
constexpr std::reverse_iterator<StaticVecIter<const T, Limit>> crbegin() const noexcept { return &arr_[size_]; }
constexpr std::reverse_iterator<T*> rend() noexcept { return &arr_[0]; }
constexpr std::reverse_iterator<StaticVecIter<T, Limit>> rend() noexcept { return &arr_[0]; }
constexpr std::reverse_iterator<const T*> crend() const noexcept { return &arr_[0]; }
constexpr std::reverse_iterator<StaticVecIter<const T, Limit>> crend() const noexcept { return &arr_[0]; }
constexpr bool empty() const noexcept { return size_ == 0; }

View file

@ -5170,8 +5170,14 @@ static void HandlePacketFromPlayer(SINT8 node)
|| netbuffer->packettype == PT_NODEKEEPALIVEMIS)
break;
// If we already received a ticcmd for this tic, just submit it for the next one.
tic_t faketic = maketic;
if (!!(netcmds[maketic % BACKUPTICS][netconsole].flags & TICCMD_RECEIVED))
faketic++;
// Copy ticcmd
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1);
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1);
// Check ticcmd for "speed hacks"
if (CheckForSpeedHacks((UINT8)netconsole))
@ -5183,7 +5189,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
&& (nodetoplayer2[node] >= 0))
{
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]],
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer2[node]],
&netbuffer->u.client2pak.cmd2, 1);
if (CheckForSpeedHacks((UINT8)nodetoplayer2[node]))
@ -5194,7 +5200,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
&& (nodetoplayer3[node] >= 0))
{
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer3[node]],
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer3[node]],
&netbuffer->u.client3pak.cmd3, 1);
if (CheckForSpeedHacks((UINT8)nodetoplayer3[node]))
@ -5204,7 +5210,7 @@ static void HandlePacketFromPlayer(SINT8 node)
if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)
&& (nodetoplayer4[node] >= 0))
{
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer4[node]],
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer4[node]],
&netbuffer->u.client4pak.cmd4, 1);
if (CheckForSpeedHacks((UINT8)nodetoplayer4[node]))

View file

@ -3303,6 +3303,7 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_INSTAWHIP_RECHARGE2",
"S_INSTAWHIP_RECHARGE3",
"S_INSTAWHIP_RECHARGE4",
"S_INSTAWHIP_REJECT",
"S_BLOCKRING",
"S_BLOCKBODY",
@ -3998,6 +3999,40 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_LAMPPOST",
"S_MOSSYTREE",
// Lost Colony symbol signs
"S_SYMBOL_0",
"S_SYMBOL_1",
"S_SYMBOL_2",
"S_SYMBOL_3",
"S_SYMBOL_4",
"S_SYMBOL_5",
"S_SYMBOL_6",
"S_SYMBOL_7",
"S_SYMBOL_8",
"S_SYMBOL_9",
"S_SYMBOL_A",
"S_SYMBOL_B",
"S_SYMBOL_C",
"S_SYMBOL_D",
"S_SYMBOL_E",
"S_SYMBOL_F",
"S_SYMBOL_G",
"S_SYMBOL_H",
"S_SYMBOL_I",
"S_SYMBOL_J",
"S_SYMBOL_K",
"S_SYMBOL_L",
"S_SYMBOL_M",
"S_SYMBOL_N",
"S_SYMBOL_O",
"S_SYMBOL_P",
"S_SYMBOL_Q",
"S_SYMBOL_R",
"S_SYMBOL_S",
"S_SYMBOL_T",
"S_SYMBOL_U",
"S_SYMBOL_V",
"S_BUMP1",
"S_BUMP2",
"S_BUMP3",
@ -4571,6 +4606,8 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_HITLAG_6",
"S_HITLAG_8",
"S_HITLAG_9",
"S_HITLAG_10",
// Broly Ki Orb
"S_BROLY1",
@ -5373,6 +5410,7 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t
"MT_INSTAWHIP",
"MT_INSTAWHIP_RECHARGE",
"MT_INSTAWHIP_REJECT",
"MT_BLOCKRING",
"MT_BLOCKBODY",
@ -5539,6 +5577,8 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t
"MT_LAMPPOST",
"MT_MOSSYTREE",
"MT_SYMBOL",
"MT_BUMP",
"MT_FLINGENERGY",

View file

@ -26,10 +26,10 @@ public:
/// @param rhi
virtual void prepass(rhi::Rhi& rhi) = 0;
/// @brief Upload contents for needed GPU resources.
/// @brief Upload contents for needed GPU resources. Passes must implement but this will be removed soon.
/// @param rhi
/// @param ctx
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) = 0;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) = 0;
/// @brief Issue draw calls.
/// @param rhi

View file

@ -141,7 +141,7 @@ static Rect get_screen_viewport(uint32_t screen, uint32_t screens, uint32_t w, u
return {0, 0, w, h};
}
void BlitPostimgScreens::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void BlitPostimgScreens::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
// Upload needed buffers
if (upload_quad_buffer_)

View file

@ -72,7 +72,7 @@ public:
virtual ~BlitPostimgScreens();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;

View file

@ -124,7 +124,7 @@ void BlitRectPass::prepass(Rhi& rhi)
}
}
void BlitRectPass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void BlitRectPass::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
if (quad_vbo_needs_upload_ && quad_vbo_)
{

View file

@ -51,7 +51,7 @@ public:
virtual ~BlitRectPass();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;

View file

@ -127,7 +127,7 @@ void ImguiPass::prepass(Rhi& rhi)
}
}
void ImguiPass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void ImguiPass::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
ImGuiIO& io = ImGui::GetIO();

View file

@ -50,7 +50,7 @@ public:
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;

View file

@ -32,7 +32,7 @@ public:
virtual ~LambdaPass();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;
};
@ -63,7 +63,7 @@ void LambdaPass::prepass(Rhi& rhi)
}
}
void LambdaPass::transfer(Rhi&, Handle<TransferContext>)
void LambdaPass::transfer(Rhi&, Handle<GraphicsContext>)
{
}
@ -137,7 +137,7 @@ void PassManager::prepass(Rhi& rhi)
}
}
void PassManager::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void PassManager::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
for (auto& pass : passes_)
{
@ -179,11 +179,8 @@ void PassManager::render(Rhi& rhi)
prepass(rhi);
Handle<TransferContext> tc = rhi.begin_transfer();
transfer(rhi, tc);
rhi.end_transfer(tc);
Handle<GraphicsContext> gc = rhi.begin_graphics();
transfer(rhi, gc);
graphics(rhi, gc);
rhi.end_graphics(gc);

View file

@ -43,7 +43,7 @@ public:
PassManager& operator=(PassManager&&) = delete;
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;

View file

@ -175,7 +175,7 @@ void PostprocessWipePass::prepass(Rhi& rhi)
});
}
void PostprocessWipePass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void PostprocessWipePass::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
if (wipe_tex_ == kNullHandle)
{

View file

@ -49,7 +49,7 @@ public:
virtual ~PostprocessWipePass();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;

View file

@ -128,7 +128,7 @@ void FramebufferManager::prepass(Rhi& rhi)
}
}
void FramebufferManager::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void FramebufferManager::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
}
@ -169,7 +169,7 @@ void MainPaletteManager::prepass(Rhi& rhi)
}
}
void MainPaletteManager::upload_palette(Rhi& rhi, Handle<TransferContext> ctx)
void MainPaletteManager::upload_palette(Rhi& rhi, Handle<GraphicsContext> ctx)
{
std::array<byteColor_t, kPaletteSize> palette_32;
for (std::size_t i = 0; i < kPaletteSize; i++)
@ -179,7 +179,7 @@ void MainPaletteManager::upload_palette(Rhi& rhi, Handle<TransferContext> ctx)
rhi.update_texture(ctx, palette_, {0, 0, kPaletteSize, 1}, PixelFormat::kRGBA8, tcb::as_bytes(tcb::span(palette_32)));
}
void MainPaletteManager::upload_lighttables(Rhi& rhi, Handle<TransferContext> ctx)
void MainPaletteManager::upload_lighttables(Rhi& rhi, Handle<GraphicsContext> ctx)
{
if (colormaps != nullptr)
{
@ -206,7 +206,7 @@ void MainPaletteManager::upload_lighttables(Rhi& rhi, Handle<TransferContext> ct
}
}
void MainPaletteManager::upload_default_colormap(Rhi& rhi, Handle<TransferContext> ctx)
void MainPaletteManager::upload_default_colormap(Rhi& rhi, Handle<GraphicsContext> ctx)
{
std::array<uint8_t, kPaletteSize> data;
for (std::size_t i = 0; i < kPaletteSize; i++)
@ -216,7 +216,7 @@ void MainPaletteManager::upload_default_colormap(Rhi& rhi, Handle<TransferContex
rhi.update_texture(ctx, default_colormap_, {0, 0, kPaletteSize, 1}, PixelFormat::kR8, tcb::as_bytes(tcb::span(data)));
}
void MainPaletteManager::upload_colormaps(Rhi& rhi, Handle<TransferContext> ctx)
void MainPaletteManager::upload_colormaps(Rhi& rhi, Handle<GraphicsContext> ctx)
{
for (auto to_upload : colormaps_to_upload_)
{
@ -279,7 +279,7 @@ rhi::Handle<rhi::Texture> MainPaletteManager::find_extra_lighttable(srb2::NotNul
return lighttables_.at(lighttable);
}
void MainPaletteManager::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void MainPaletteManager::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
upload_palette(rhi, ctx);
upload_lighttables(rhi, ctx);
@ -327,7 +327,7 @@ void CommonResourcesManager::prepass(Rhi& rhi)
}
}
void CommonResourcesManager::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void CommonResourcesManager::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
if (!init_)
{
@ -382,7 +382,7 @@ void FlatTextureManager::prepass(Rhi& rhi)
{
}
void FlatTextureManager::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void FlatTextureManager::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
std::vector<std::array<uint8_t, 2>> flat_data;
for (auto flat_lump : to_upload_)

View file

@ -37,7 +37,7 @@ public:
virtual ~FramebufferManager();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;
@ -83,17 +83,17 @@ class MainPaletteManager final : public Pass
std::vector<const uint8_t*> colormaps_to_upload_;
std::vector<const uint8_t*> lighttables_to_upload_;
void upload_palette(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx);
void upload_lighttables(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx);
void upload_default_colormap(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx);
void upload_colormaps(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx);
void upload_palette(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx);
void upload_lighttables(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx);
void upload_default_colormap(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx);
void upload_colormaps(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx);
public:
MainPaletteManager();
virtual ~MainPaletteManager();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;
@ -120,7 +120,7 @@ public:
virtual ~CommonResourcesManager();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;
@ -153,7 +153,7 @@ public:
virtual ~FlatTextureManager();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;

View file

@ -40,7 +40,7 @@ void ScreenshotPass::prepass(Rhi& rhi)
doing_screenshot_ = takescreenshot || moviemode != MM_OFF;
}
void ScreenshotPass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void ScreenshotPass::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
}

View file

@ -32,7 +32,7 @@ public:
virtual ~ScreenshotPass();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;

View file

@ -77,7 +77,7 @@ void SoftwarePass::prepass(Rhi& rhi)
}
}
void SoftwarePass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void SoftwarePass::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
// Upload screen
tcb::span<const std::byte> screen_span;

View file

@ -34,7 +34,7 @@ public:
virtual ~SoftwarePass();
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;

View file

@ -498,7 +498,7 @@ void TwodeePass::prepass(Rhi& rhi)
}
}
void TwodeePass::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void TwodeePass::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
if (!ctx_ || !data_)
{

View file

@ -97,7 +97,7 @@ struct TwodeePass final : public Pass
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;

View file

@ -348,7 +348,7 @@ void PatchAtlasCache::prepass(Rhi& rhi)
}
}
void PatchAtlasCache::transfer(Rhi& rhi, Handle<TransferContext> ctx)
void PatchAtlasCache::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
{
SRB2_ASSERT(ready_for_lookup());

View file

@ -125,7 +125,7 @@ public:
PatchAtlas* find_patch(srb2::NotNull<const patch_t*> patch);
virtual void prepass(rhi::Rhi& rhi) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::TransferContext> ctx) override;
virtual void transfer(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void graphics(rhi::Rhi& rhi, rhi::Handle<rhi::GraphicsContext> ctx) override;
virtual void postpass(rhi::Rhi& rhi) override;
};

View file

@ -558,6 +558,7 @@ char sprnames[NUMSPRITES + 1][5] =
"IWHP", // Instawhip
"WPRE", // Instawhip Recharge
"WPRJ", // Instawhip Reject
"GRNG", // Guard ring
"GBDY", // Guard body
@ -581,6 +582,7 @@ char sprnames[NUMSPRITES + 1][5] =
"HFX6", // Hitlag stage 6
"HFX8", // Hitlag stage 8
"HFX9", // Hitlag stage 9
"HFXX", // Hitlag stage 10
// Kart Items
"RSHE", // Rocket sneaker
@ -644,6 +646,40 @@ char sprnames[NUMSPRITES + 1][5] =
"CRAB", // Crystal Abyss mobs
"BRNG", // Chaotix Big Ring
// Lost Colony symbol signs
"SYM0",
"SYM1",
"SYM2",
"SYM3",
"SYM4",
"SYM5",
"SYM6",
"SYM7",
"SYM8",
"SYM9",
"SYMA",
"SYMB",
"SYMC",
"SYMD",
"SYME",
"SYMF",
"SYMG",
"SYMH",
"SYMI",
"SYMJ",
"SYMK",
"SYML",
"SYMM",
"SYMN",
"SYMO",
"SYMP",
"SYMQ",
"SYMR",
"SYMS",
"SYMT",
"SYMU",
"SYMV",
"BUMP", // Player/shell bump
"FLEN", // Shell hit graphics stuff
"CLAS", // items clash
@ -3988,6 +4024,7 @@ state_t states[NUMSTATES] =
{SPR_NULL, 0, 0, {A_PlaySound}, sfx_s3ka0, 2, S_INSTAWHIP_RECHARGE3}, // S_INSTAWHIP_RECHARGE2
{SPR_WPRE, FF_FULLBRIGHT|FF_FLOORSPRITE|FF_ANIMATE|0, 36, {NULL}, 17, 2, S_INSTAWHIP_RECHARGE4}, // S_INSTAWHIP_RECHARGE3
{SPR_NULL, 0, 0, {A_PlaySound}, sfx_s3k7c, 2, S_NULL}, // S_INSTAWHIP_RECHARGE4
{SPR_WPRJ, FF_ANIMATE, 9, {NULL}, 8, 1, S_NULL}, // S_INSTAWHIP_REJECT
{SPR_GRNG, FF_FULLBRIGHT|FF_PAPERSPRITE|0, -1, {NULL}, 0, 0, S_NULL}, // S_BLOCKRING
{SPR_GBDY, FF_FULLBRIGHT|FF_ANIMATE|0, -1, {NULL}, 4, 2, S_NULL}, // S_BLOCKBODY
@ -4639,6 +4676,40 @@ state_t states[NUMSTATES] =
{SPR_CRAB, 10, -1, {NULL}, 0, 0, S_NULL}, // S_LAMPPOST
{SPR_CRAB, 11, -1, {NULL}, 0, 0, S_NULL}, // S_MOSSYTREE
// Lost Colony symbol signs
{SPR_SYM0, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_0
{SPR_SYM1, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_1
{SPR_SYM2, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_2
{SPR_SYM3, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_3
{SPR_SYM4, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_4
{SPR_SYM5, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_5
{SPR_SYM6, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_6
{SPR_SYM7, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_7
{SPR_SYM8, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_8
{SPR_SYM9, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_9
{SPR_SYMA, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_A
{SPR_SYMB, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_B
{SPR_SYMC, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_C
{SPR_SYMD, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_D
{SPR_SYME, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_E
{SPR_SYMF, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_F
{SPR_SYMG, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_G
{SPR_SYMH, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_H
{SPR_SYMI, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_I
{SPR_SYMJ, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_J
{SPR_SYMK, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_K
{SPR_SYML, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_L
{SPR_SYMM, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_M
{SPR_SYMN, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_N
{SPR_SYMO, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_O
{SPR_SYMP, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_P
{SPR_SYMQ, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_Q
{SPR_SYMR, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_R
{SPR_SYMS, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_S
{SPR_SYMT, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_T
{SPR_SYMU, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_U
{SPR_SYMV, FF_ANIMATE|FF_PAPERSPRITE, -1, {NULL}, 15, 2, S_NULL}, // S_SYMBOL_V
{SPR_BUMP, FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_BUMP2}, // S_BUMP1
{SPR_BUMP, FF_FULLBRIGHT|1, 3, {NULL}, 0, 0, S_BUMP3}, // S_BUMP2
{SPR_BUMP, FF_FULLBRIGHT|2, 3, {NULL}, 0, 0, S_NULL}, // S_BUMP3
@ -5252,6 +5323,7 @@ state_t states[NUMSTATES] =
{SPR_HFX6, FF_FULLBRIGHT|FF_PAPERSPRITE|FF_ANIMATE, 6, {NULL}, 5, 1, S_NULL}, // S_HITLAG_6
{SPR_HFX8, FF_FULLBRIGHT|FF_PAPERSPRITE|FF_ANIMATE, 8, {NULL}, 7, 1, S_NULL}, // S_HITLAG_8
{SPR_HFX9, FF_FULLBRIGHT|FF_PAPERSPRITE|FF_ANIMATE, 9, {NULL}, 8, 1, S_NULL}, // S_HITLAG_9
{SPR_HFXX, FF_FULLBRIGHT|FF_PAPERSPRITE|FF_ANIMATE, 10, {NULL}, 9, 1, S_NULL}, // S_HITLAG_10
// Broly Ki Orb
{SPR_LSSJ, FF_REVERSESUBTRACT|FF_FULLBRIGHT, -1, {NULL}, 0, 0, S_BROLY2}, // S_BROLY1
@ -22793,6 +22865,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
S_INSTAWHIP_RECHARGE3 // raisestate
},
{ // MT_INSTAWHIP_REJECT
-1, // doomednum
S_INSTAWHIP_REJECT, // spawnstate
1000, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
0, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_NULL, // missilestate
S_NULL, // deathstate
S_NULL, // xdeathstate
sfx_None, // deathsound
0, // speed
90*FRACUNIT, // radius
90*FRACUNIT, // height
0, // display offset
100, // mass
0, // damage
sfx_None, // activesound
MF_NOGRAVITY|MF_NOCLIPHEIGHT|MF_DONTENCOREMAP, // flags
S_NULL // raisestate
},
{ // MT_BLOCKRING
-1, // doomednum
S_BLOCKRING, // spawnstate
@ -26222,6 +26321,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
S_NULL // raisestate
},
{ // MT_SYMBOL
4094, // doomednum
S_SYMBOL_0, // spawnstate
1000, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
8, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_NULL, // missilestate
S_NULL, // deathstate
S_NULL, // xdeathstate
sfx_None, // deathsound
0, // speed
43*FRACUNIT, // radius
100*FRACUNIT, // height
0, // display offset
100, // mass
0, // damage
sfx_None, // activesound
MF_NOGRAVITY|MF_SCENERY|MF_NOCLIP|MF_DRAWFROMFARAWAY|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_DONTENCOREMAP, // flags
S_NULL // raisestate
},
{ // MT_BUMP
-1, // doomednum
S_BUMP1, // spawnstate

View file

@ -1109,6 +1109,7 @@ typedef enum sprite
SPR_IWHP, // Instawhip
SPR_WPRE, // Instawhip Recharge
SPR_WPRJ, // Instawhip Reject
SPR_GRNG, // Guard ring
SPR_GBDY, // Guard body
@ -1132,6 +1133,7 @@ typedef enum sprite
SPR_HFX6, // Hitlag stage 6
SPR_HFX8, // Hitlag stage 8
SPR_HFX9, // Hitlag stage 9
SPR_HFXX, // Hitlag stage 10
// Kart Items
SPR_RSHE, // Rocket sneaker
@ -1195,6 +1197,40 @@ typedef enum sprite
SPR_CRAB, // Crystal Abyss mobs
SPR_BRNG, // Chaotix Big Ring
// Lost Colony symbol signs
SPR_SYM0,
SPR_SYM1,
SPR_SYM2,
SPR_SYM3,
SPR_SYM4,
SPR_SYM5,
SPR_SYM6,
SPR_SYM7,
SPR_SYM8,
SPR_SYM9,
SPR_SYMA,
SPR_SYMB,
SPR_SYMC,
SPR_SYMD,
SPR_SYME,
SPR_SYMF,
SPR_SYMG,
SPR_SYMH,
SPR_SYMI,
SPR_SYMJ,
SPR_SYMK,
SPR_SYML,
SPR_SYMM,
SPR_SYMN,
SPR_SYMO,
SPR_SYMP,
SPR_SYMQ,
SPR_SYMR,
SPR_SYMS,
SPR_SYMT,
SPR_SYMU,
SPR_SYMV,
SPR_BUMP, // Player/shell bump
SPR_FLEN, // Shell hit graphics stuff
SPR_CLAS, // items clash
@ -4398,6 +4434,7 @@ typedef enum state
S_INSTAWHIP_RECHARGE2,
S_INSTAWHIP_RECHARGE3,
S_INSTAWHIP_RECHARGE4,
S_INSTAWHIP_REJECT,
S_BLOCKRING,
S_BLOCKBODY,
@ -5092,6 +5129,40 @@ typedef enum state
S_LAMPPOST,
S_MOSSYTREE,
// Lost Colony symbol signs
S_SYMBOL_0,
S_SYMBOL_1,
S_SYMBOL_2,
S_SYMBOL_3,
S_SYMBOL_4,
S_SYMBOL_5,
S_SYMBOL_6,
S_SYMBOL_7,
S_SYMBOL_8,
S_SYMBOL_9,
S_SYMBOL_A,
S_SYMBOL_B,
S_SYMBOL_C,
S_SYMBOL_D,
S_SYMBOL_E,
S_SYMBOL_F,
S_SYMBOL_G,
S_SYMBOL_H,
S_SYMBOL_I,
S_SYMBOL_J,
S_SYMBOL_K,
S_SYMBOL_L,
S_SYMBOL_M,
S_SYMBOL_N,
S_SYMBOL_O,
S_SYMBOL_P,
S_SYMBOL_Q,
S_SYMBOL_R,
S_SYMBOL_S,
S_SYMBOL_T,
S_SYMBOL_U,
S_SYMBOL_V,
S_BUMP1,
S_BUMP2,
S_BUMP3,
@ -5682,6 +5753,7 @@ typedef enum state
S_HITLAG_6,
S_HITLAG_8,
S_HITLAG_9,
S_HITLAG_10,
// Broly Ki Orb
S_BROLY1,
@ -6503,6 +6575,7 @@ typedef enum mobj_type
MT_INSTAWHIP,
MT_INSTAWHIP_RECHARGE,
MT_INSTAWHIP_REJECT,
MT_BLOCKRING,
MT_BLOCKBODY,
@ -6669,6 +6742,8 @@ typedef enum mobj_type
MT_LAMPPOST,
MT_MOSSYTREE,
MT_SYMBOL, // Lost Colony symbol signs
MT_BUMP,
MT_FLINGENERGY,

View file

@ -22,7 +22,7 @@ extern "C" {
#define MAXHITLAGTICS (30)
#define HITLAGJITTERS (FRACUNIT / 20)
#define NUM_HITLAG_STATES (8)
#define NUM_HITLAG_STATES (9)
/*--------------------------------------------------
void K_AddHitLag(mobj_t *mo, INT32 tics, boolean fromDamage);

View file

@ -178,6 +178,11 @@ void Obj_BattleUFOBeamThink(mobj_t *beam);
void Obj_SpawnPowerUpAura(player_t* player);
void Obj_PowerUpAuraThink(mobj_t* mobj);
/* Lost Colony symbol signs */
void Obj_SymbolSpawn(mobj_t *mobj);
void Obj_SymbolSetup(mobj_t *mobj, mapthing_t *mthing);
void Obj_SymbolThink(mobj_t *mobj);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -24,4 +24,5 @@ target_sources(SRB2SDL2 PRIVATE
super-flicky.cpp
battle-ufo.cpp
powerup-aura.cpp
symbol.c
)

43
src/objects/symbol.c Normal file
View file

@ -0,0 +1,43 @@
#include "../p_local.h"
#include "../k_objects.h"
#define SYMBOL_SCALE (2<<FRACBITS)
#define SYMBOL_ZOFFSET (19<<FRACBITS)
#define SYMBOL_BOBRANGE (64<<FRACBITS)
#define SYMBOL_BOBSPEED (5<<FRACBITS)
#define SYMBOL_OPTIONS 32
void Obj_SymbolSpawn(mobj_t *mobj)
{
mobj->extravalue1 = mobj->z;
mobj->extravalue2 = FixedMul(mobj->x + mobj->y, mapobjectscale);
}
void Obj_SymbolSetup(mobj_t *mobj, mapthing_t *mthing)
{
fixed_t oldHeight = mobj->height;
statenum_t stateNum = mobj->info->spawnstate + (mthing->args[0] % SYMBOL_OPTIONS);
mobj->angle += ANGLE_90;
P_SetScale(mobj, mobj->destscale = 4 * FixedMul(mobj->scale, SYMBOL_SCALE));
mobj->z += 4 * FixedMul(mapobjectscale, SYMBOL_ZOFFSET) * P_MobjFlip(mobj);
if (mthing->options & MTF_OBJECTFLIP)
{
mobj->z += oldHeight - mobj->height;
}
mobj->extravalue1 = mobj->old_z = mobj->z;
P_SetMobjState(mobj, stateNum);
}
void Obj_SymbolThink(mobj_t *mobj)
{
fixed_t offset = FixedMul(mapobjectscale,
FixedMul(SYMBOL_BOBRANGE,
FixedMul(FINESINE(FixedAngle(leveltime * SYMBOL_BOBSPEED + mobj->extravalue2) >> ANGLETOFINESHIFT) + FRACUNIT, FRACUNIT >> 1)
)
);
mobj->z = mobj->extravalue1 + P_MobjFlip(mobj) * offset;
}

View file

@ -6712,6 +6712,9 @@ static void P_MobjSceneryThink(mobj_t *mobj)
return;
}
break;
case MT_SYMBOL:
Obj_SymbolThink(mobj);
break;
case MT_VWREF:
case MT_VWREB:
{
@ -10974,6 +10977,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
case MT_BATTLEUFO:
Obj_SpawnBattleUFOLegs(mobj);
break;
case MT_SYMBOL:
Obj_SymbolSpawn(mobj);
break;
default:
break;
}
@ -13493,6 +13499,11 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj)
Obj_LinkBattleUFOSpawner(mobj);
break;
}
case MT_SYMBOL:
{
Obj_SymbolSetup(mobj, mthing);
break;
}
default:
break;
}

View file

@ -7202,6 +7202,14 @@ static void P_ConvertBinaryThingTypes(void)
case CEILING_SLOPE_THING:
mapthings[i].args[0] = mapthings[i].extrainfo;
break;
case 4094: // MT_SYMBOL
mapthings[i].args[0] = mapthings[i].extrainfo;
if (mapthings[i].options & MTF_OBJECTSPECIAL)
{
// Special = add 16 to the symbol type
mapthings[i].args[0] += 16;
}
break;
default:
break;
}

View file

@ -2380,7 +2380,24 @@ static void P_UpdatePlayerAngle(player_t *player)
INT16 targetsteering = K_UpdateSteeringValue(player->steering, player->cmd.turning);
angleChange = K_GetKartTurnValue(player, targetsteering) << TICCMD_REDUCE;
if (!K_PlayerUsesBotMovement(player))
if (K_PlayerUsesBotMovement(player))
{
// You're a bot. Go where you're supposed to go
player->steering = targetsteering;
}
else if ((!(player->cmd.flags & TICCMD_RECEIVED)) && (!!(player->oldcmd.flags && TICCMD_RECEIVED)))
{
// Missed a single tic. This ticcmd is copied from their previous one
// (less the TICCMD_RECEIVED flag), so it will include an old angle, and
// steering towards that will turn unambitiously. A better guess is to
// assume their inputs are the same, and turn based on those for 1 tic.
player->steering = targetsteering;
// "Why not use this for multiple consecutive dropped tics?" Oversimplification:
// Clients have default netticbuffer 1, so missing more than 1 tic will freeze
// your client, and with it, your local camera. Our goal then becomes not to
// steer PAST the angle you can see, so the default turn solver behavior is best.
}
else
{
// With a full slam on the analog stick, how far could we steer in either direction?
INT16 steeringRight = K_UpdateSteeringValue(player->steering, KART_FULLTURN);
@ -2431,11 +2448,6 @@ static void P_UpdatePlayerAngle(player_t *player)
angleChange = targetDelta;
}
}
else
{
// You're a bot. Go where you're supposed to go
player->steering = targetsteering;
}
if (p == UINT8_MAX)
{

View file

@ -568,8 +568,6 @@ GlCoreRhi::~GlCoreRhi() = default;
rhi::Handle<rhi::RenderPass> GlCoreRhi::create_render_pass(const rhi::RenderPassDesc& desc)
{
SRB2_ASSERT(graphics_context_active_ == false);
// GL has no formal render pass object
GlCoreRenderPass pass;
pass.desc = desc;
@ -578,15 +576,11 @@ rhi::Handle<rhi::RenderPass> GlCoreRhi::create_render_pass(const rhi::RenderPass
void GlCoreRhi::destroy_render_pass(rhi::Handle<rhi::RenderPass> handle)
{
SRB2_ASSERT(graphics_context_active_ == false);
render_pass_slab_.remove(handle);
}
rhi::Handle<rhi::Texture> GlCoreRhi::create_texture(const rhi::TextureDesc& desc)
{
SRB2_ASSERT(graphics_context_active_ == false);
GLenum internal_format = map_internal_texture_format(desc.format);
SRB2_ASSERT(internal_format != GL_ZERO);
GLenum format = GL_RGBA;
@ -615,8 +609,6 @@ rhi::Handle<rhi::Texture> GlCoreRhi::create_texture(const rhi::TextureDesc& desc
void GlCoreRhi::destroy_texture(rhi::Handle<rhi::Texture> handle)
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(texture_slab_.is_valid(handle) == true);
GlCoreTexture casted = texture_slab_.remove(handle);
GLuint name = casted.texture;
@ -624,16 +616,14 @@ void GlCoreRhi::destroy_texture(rhi::Handle<rhi::Texture> handle)
}
void GlCoreRhi::update_texture(
Handle<TransferContext> ctx,
Handle<GraphicsContext> ctx,
Handle<Texture> texture,
Rect region,
srb2::rhi::PixelFormat data_format,
tcb::span<const std::byte> data
)
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(transfer_context_active_ == true);
SRB2_ASSERT(ctx.generation() == transfer_context_generation_);
SRB2_ASSERT(graphics_context_active_ == true);
if (data.empty())
{
@ -678,8 +668,6 @@ void GlCoreRhi::update_texture(
rhi::Handle<rhi::Buffer> GlCoreRhi::create_buffer(const rhi::BufferDesc& desc)
{
SRB2_ASSERT(graphics_context_active_ == false);
GLenum target = map_buffer_type(desc.type);
SRB2_ASSERT(target != GL_ZERO);
@ -704,10 +692,7 @@ rhi::Handle<rhi::Buffer> GlCoreRhi::create_buffer(const rhi::BufferDesc& desc)
void GlCoreRhi::destroy_buffer(rhi::Handle<rhi::Buffer> handle)
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(buffer_slab_.is_valid(handle) == true);
SRB2_ASSERT(graphics_context_active_ == false);
GlCoreBuffer casted = buffer_slab_.remove(handle);
GLuint name = casted.buffer;
@ -715,15 +700,14 @@ void GlCoreRhi::destroy_buffer(rhi::Handle<rhi::Buffer> handle)
}
void GlCoreRhi::update_buffer(
rhi::Handle<TransferContext> ctx,
rhi::Handle<GraphicsContext> ctx,
rhi::Handle<rhi::Buffer> handle,
uint32_t offset,
tcb::span<const std::byte> data
)
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(transfer_context_active_ == true);
SRB2_ASSERT(ctx.generation() == transfer_context_generation_);
SRB2_ASSERT(graphics_context_active_ == true);
SRB2_ASSERT(ctx.generation() == graphics_context_generation_);
if (data.empty())
{
@ -753,11 +737,10 @@ void GlCoreRhi::update_buffer(
}
rhi::Handle<rhi::UniformSet>
GlCoreRhi::create_uniform_set(rhi::Handle<rhi::TransferContext> ctx, const rhi::CreateUniformSetInfo& info)
GlCoreRhi::create_uniform_set(rhi::Handle<rhi::GraphicsContext> ctx, const rhi::CreateUniformSetInfo& info)
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(transfer_context_active_ == true);
SRB2_ASSERT(ctx.generation() == transfer_context_generation_);
SRB2_ASSERT(graphics_context_active_ == true);
SRB2_ASSERT(ctx.generation() == graphics_context_generation_);
GlCoreUniformSet uniform_set;
@ -770,14 +753,13 @@ GlCoreRhi::create_uniform_set(rhi::Handle<rhi::TransferContext> ctx, const rhi::
}
rhi::Handle<rhi::BindingSet> GlCoreRhi::create_binding_set(
rhi::Handle<rhi::TransferContext> ctx,
rhi::Handle<rhi::GraphicsContext> ctx,
Handle<Pipeline> pipeline,
const rhi::CreateBindingSetInfo& info
)
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(transfer_context_active_ == true);
SRB2_ASSERT(ctx.generation() == transfer_context_generation_);
SRB2_ASSERT(graphics_context_active_ == true);
SRB2_ASSERT(ctx.generation() == graphics_context_generation_);
SRB2_ASSERT(pipeline_slab_.is_valid(pipeline) == true);
auto& pl = pipeline_slab_[pipeline];
@ -842,8 +824,6 @@ rhi::Handle<rhi::BindingSet> GlCoreRhi::create_binding_set(
rhi::Handle<rhi::Renderbuffer> GlCoreRhi::create_renderbuffer(const rhi::RenderbufferDesc& desc)
{
SRB2_ASSERT(graphics_context_active_ == false);
GLuint name = 0;
gl_->GenRenderbuffers(1, &name);
@ -876,8 +856,6 @@ rhi::Handle<rhi::Renderbuffer> GlCoreRhi::create_renderbuffer(const rhi::Renderb
void GlCoreRhi::destroy_renderbuffer(rhi::Handle<rhi::Renderbuffer> handle)
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(renderbuffer_slab_.is_valid(handle) == true);
GlCoreRenderbuffer casted = renderbuffer_slab_.remove(handle);
GLuint name = casted.renderbuffer;
@ -1192,8 +1170,6 @@ rhi::Handle<rhi::Pipeline> GlCoreRhi::create_pipeline(const PipelineDesc& desc)
void GlCoreRhi::destroy_pipeline(rhi::Handle<rhi::Pipeline> handle)
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(pipeline_slab_.is_valid(handle) == true);
GlCorePipeline casted = pipeline_slab_.remove(handle);
GLuint vertex_shader = casted.vertex_shader;
@ -1222,25 +1198,6 @@ void GlCoreRhi::end_graphics(rhi::Handle<rhi::GraphicsContext> handle)
GL_ASSERT;
}
rhi::Handle<rhi::TransferContext> GlCoreRhi::begin_transfer()
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(transfer_context_active_ == false);
transfer_context_generation_ += 1;
transfer_context_active_ = true;
return rhi::Handle<rhi::TransferContext>(0, transfer_context_generation_);
}
void GlCoreRhi::end_transfer(rhi::Handle<rhi::TransferContext> ctx)
{
SRB2_ASSERT(graphics_context_active_ == false);
SRB2_ASSERT(transfer_context_active_ == true);
transfer_context_active_ = false;
}
void GlCoreRhi::present()
{
SRB2_ASSERT(platform_ != nullptr);
@ -1269,7 +1226,7 @@ void GlCoreRhi::begin_default_render_pass(Handle<GraphicsContext> ctx, bool clea
gl_->ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
gl_->ClearDepth(1.0f);
gl_->ClearStencil(0);
gl_->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl_->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
GL_ASSERT;
}
@ -1661,7 +1618,6 @@ void GlCoreRhi::bind_binding_set(Handle<GraphicsContext> ctx, Handle<BindingSet>
void GlCoreRhi::bind_index_buffer(Handle<GraphicsContext> ctx, Handle<Buffer> buffer)
{
SRB2_ASSERT(transfer_context_active_ == false);
SRB2_ASSERT(graphics_context_active_ == true && graphics_context_generation_ == ctx.generation());
SRB2_ASSERT(current_render_pass_.has_value() == true && current_pipeline_.has_value() == true);

View file

@ -123,10 +123,6 @@ struct GlCoreGraphicsContext : public rhi::GraphicsContext
{
};
struct GlCoreTransferContext : public rhi::TransferContext
{
};
struct GlCoreActiveUniform
{
uint32_t type;
@ -159,10 +155,8 @@ class GlCoreRhi final : public Rhi
std::optional<Handle<Pipeline>> current_pipeline_;
PrimitiveType current_primitive_type_ = PrimitiveType::kPoints;
bool graphics_context_active_ = false;
bool transfer_context_active_ = false;
uint32_t graphics_context_generation_ = 0;
uint32_t index_buffer_offset_ = 0;
uint32_t transfer_context_generation_ = 0;
uint8_t stencil_front_reference_ = 0;
uint8_t stencil_front_compare_mask_ = 0xFF;
@ -193,26 +187,23 @@ public:
virtual Rect get_renderbuffer_size(Handle<Renderbuffer> renderbuffer) override;
virtual uint32_t get_buffer_size(Handle<Buffer> buffer) override;
virtual Handle<TransferContext> begin_transfer() override;
virtual void end_transfer(Handle<TransferContext> handle) override;
virtual void update_buffer(
Handle<TransferContext> ctx,
Handle<GraphicsContext> ctx,
Handle<Buffer> buffer,
uint32_t offset,
tcb::span<const std::byte> data
) override;
virtual void update_texture(
Handle<TransferContext> ctx,
Handle<GraphicsContext> ctx,
Handle<Texture> texture,
Rect region,
srb2::rhi::PixelFormat data_format,
tcb::span<const std::byte> data
) override;
virtual Handle<UniformSet>
create_uniform_set(Handle<TransferContext> ctx, const CreateUniformSetInfo& info) override;
create_uniform_set(Handle<GraphicsContext> ctx, const CreateUniformSetInfo& info) override;
virtual Handle<BindingSet>
create_binding_set(Handle<TransferContext> ctx, Handle<Pipeline> pipeline, const CreateBindingSetInfo& info)
create_binding_set(Handle<GraphicsContext> ctx, Handle<Pipeline> pipeline, const CreateBindingSetInfo& info)
override;
virtual Handle<GraphicsContext> begin_graphics() override;

View file

@ -569,9 +569,6 @@ struct BindingSet
{
};
struct TransferContext
{
};
struct GraphicsContext
{
};
@ -607,26 +604,22 @@ struct Rhi
virtual Rect get_renderbuffer_size(Handle<Renderbuffer> renderbuffer) = 0;
virtual uint32_t get_buffer_size(Handle<Buffer> buffer) = 0;
virtual Handle<TransferContext> begin_transfer() = 0;
virtual void end_transfer(Handle<TransferContext> handle) = 0;
// Transfer Context functions
virtual void update_buffer(
Handle<TransferContext> ctx,
Handle<GraphicsContext> ctx,
Handle<Buffer> buffer,
uint32_t offset,
tcb::span<const std::byte> data
) = 0;
virtual void update_texture(
Handle<TransferContext> ctx,
Handle<GraphicsContext> ctx,
Handle<Texture> texture,
Rect region,
srb2::rhi::PixelFormat data_format,
tcb::span<const std::byte> data
) = 0;
virtual Handle<UniformSet> create_uniform_set(Handle<TransferContext> ctx, const CreateUniformSetInfo& info) = 0;
virtual Handle<UniformSet> create_uniform_set(Handle<GraphicsContext> ctx, const CreateUniformSetInfo& info) = 0;
virtual Handle<BindingSet>
create_binding_set(Handle<TransferContext> ctx, Handle<Pipeline> pipeline, const CreateBindingSetInfo& info) = 0;
create_binding_set(Handle<GraphicsContext> ctx, Handle<Pipeline> pipeline, const CreateBindingSetInfo& info) = 0;
virtual Handle<GraphicsContext> begin_graphics() = 0;
virtual void end_graphics(Handle<GraphicsContext> ctx) = 0;