From 2cedb48de2a6b9528297cd59c72150a6f5f37a0b Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Wed, 13 Aug 2025 17:20:49 +0200 Subject: [PATCH] Remove custom span and use std::span With C++20 the custom container PS:span, which was a backport of std::span is no longer needed. Signed-off-by: Ralph Sennhauser --- source/graphics/Canvas2D.cpp | 1 - source/graphics/Color.h | 6 +- source/graphics/Font.cpp | 4 +- source/graphics/LOSTexture.cpp | 1 - source/graphics/MiniMapTexture.cpp | 1 - source/graphics/ModelDef.cpp | 1 - source/graphics/ParticleEmitter.cpp | 1 - source/main.cpp | 4 +- source/maths/Matrix3D.h | 6 +- source/maths/Vector2D.h | 7 +- source/maths/Vector3D.h | 7 +- source/maths/Vector4D.h | 7 +- source/network/NetEnet.cpp | 6 +- source/ps/GameSetup/CmdLineArgs.cpp | 3 +- source/ps/GameSetup/CmdLineArgs.h | 3 +- source/ps/GameSetup/tests/test_CmdLineArgs.h | 4 +- source/ps/containers/Span.h | 89 ------------------- source/renderer/CPUSkinnedModelRenderer.cpp | 5 +- source/renderer/CPUSkinnedModelRenderer.h | 5 +- source/renderer/DebugRenderer.cpp | 1 - source/renderer/DecalRData.cpp | 1 - source/renderer/GPUSkinnedModelRenderer.cpp | 7 +- source/renderer/GPUSkinnedModelRenderer.h | 5 +- source/renderer/InstancingModelRenderer.cpp | 5 +- source/renderer/InstancingModelRenderer.h | 8 +- source/renderer/ModelRenderer.cpp | 4 +- source/renderer/ModelVertexRenderer.h | 7 +- source/renderer/OverlayRenderer.cpp | 1 - source/renderer/PatchRData.cpp | 1 - source/renderer/PostprocManager.cpp | 1 - source/renderer/Renderer.cpp | 3 +- source/renderer/Renderer.h | 4 +- source/renderer/ShadowMap.cpp | 6 +- source/renderer/SilhouetteRenderer.cpp | 1 - source/renderer/SkyManager.cpp | 1 - source/renderer/TerrainOverlay.cpp | 1 - source/renderer/TerrainRenderer.cpp | 1 - source/renderer/TexturedLineRData.cpp | 1 - source/renderer/WaterManager.cpp | 1 - source/renderer/backend/IDevice.h | 4 +- .../renderer/backend/IDeviceCommandContext.h | 5 +- source/renderer/backend/dummy/Device.cpp | 3 +- source/renderer/backend/dummy/Device.h | 3 +- .../backend/dummy/DeviceCommandContext.cpp | 3 +- .../backend/dummy/DeviceCommandContext.h | 3 +- source/renderer/backend/gl/Device.cpp | 3 +- source/renderer/backend/gl/Device.h | 3 +- .../backend/gl/DeviceCommandContext.cpp | 3 +- .../backend/gl/DeviceCommandContext.h | 3 +- source/renderer/backend/gl/ShaderProgram.cpp | 10 +-- source/renderer/backend/gl/ShaderProgram.h | 6 +- source/renderer/backend/gl/Texture.cpp | 1 - source/renderer/backend/vulkan/Device.cpp | 3 +- source/renderer/backend/vulkan/Device.h | 3 +- .../backend/vulkan/DeviceCommandContext.cpp | 17 ++-- .../backend/vulkan/DeviceCommandContext.h | 3 +- .../renderer/backend/vulkan/ShaderProgram.cpp | 10 +-- .../renderer/backend/vulkan/ShaderProgram.h | 6 +- source/soundmanager/data/OggData.cpp | 4 +- source/soundmanager/data/ogg.cpp | 3 +- source/soundmanager/data/ogg.h | 5 +- source/soundmanager/items/CSoundBase.cpp | 1 - 62 files changed, 108 insertions(+), 218 deletions(-) delete mode 100644 source/ps/containers/Span.h diff --git a/source/graphics/Canvas2D.cpp b/source/graphics/Canvas2D.cpp index cd76bb15f4..5b7015d442 100644 --- a/source/graphics/Canvas2D.cpp +++ b/source/graphics/Canvas2D.cpp @@ -33,7 +33,6 @@ #include "maths/Vector2D.h" #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" -#include "ps/containers/Span.h" #include "ps/containers/StaticVector.h" #include "renderer/Renderer.h" #include "renderer/backend/Format.h" diff --git a/source/graphics/Color.h b/source/graphics/Color.h index 6ef31eff1e..4b5dcfb522 100644 --- a/source/graphics/Color.h +++ b/source/graphics/Color.h @@ -22,8 +22,8 @@ #include "lib/types.h" #include "maths/Vector3D.h" #include "maths/Vector4D.h" -#include "ps/containers/Span.h" +#include #include class CStr8; @@ -71,7 +71,7 @@ struct CColor } // For passing to uniform as vec3/vec4. - PS::span AsFloatArray() const + std::span AsFloatArray() const { // Additional check to prevent a weird compiler has a different // alignement for an array and a class members. @@ -82,7 +82,7 @@ struct CColor offsetof(CColor, b) == sizeof(float) * 2u && offsetof(CColor, a) == sizeof(float) * 3u, "CColor should be properly layouted to use AsFloatArray"); - return PS::span(&r, 4); + return std::span(&r, 4); } // For passing to CRenderer: diff --git a/source/graphics/Font.cpp b/source/graphics/Font.cpp index 88134a171c..cd907b5225 100644 --- a/source/graphics/Font.cpp +++ b/source/graphics/Font.cpp @@ -25,7 +25,6 @@ #include "ps/CLogger.h" #include "ps/Filesystem.h" #include "ps/Profiler2.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "renderer/backend/IDevice.h" #include "renderer/backend/IDeviceCommandContext.h" @@ -38,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -528,7 +528,7 @@ void CFont::BlendGlyphBitmapToTextureRGBA(const FT_Bitmap& bitmap, int targetX, for (uint x{0}; x != bitmap.width; ++x) { - const PS::span tempDstRow{dstRow + x * m_TextureFormatStride, 4}; + const std::span tempDstRow{dstRow + x * m_TextureFormatStride, 4}; u8 alpha{srcRow[x]}; const float srcAlpha{m_StrokeWidth > 0 ? (*m_GammaCorrectionLUT)[alpha] : alpha/255.0f}; diff --git a/source/graphics/LOSTexture.cpp b/source/graphics/LOSTexture.cpp index 330176ecc0..cabdcd7f4e 100644 --- a/source/graphics/LOSTexture.cpp +++ b/source/graphics/LOSTexture.cpp @@ -30,7 +30,6 @@ #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" #include "ps/Profile.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "renderer/RenderingOptions.h" #include "renderer/TimeManager.h" diff --git a/source/graphics/MiniMapTexture.cpp b/source/graphics/MiniMapTexture.cpp index b7a3f6301b..f7b7c41ad4 100644 --- a/source/graphics/MiniMapTexture.cpp +++ b/source/graphics/MiniMapTexture.cpp @@ -47,7 +47,6 @@ #include "ps/Profile.h" #include "ps/World.h" #include "ps/XML/Xeromyces.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "renderer/SceneRenderer.h" #include "renderer/WaterManager.h" diff --git a/source/graphics/ModelDef.cpp b/source/graphics/ModelDef.cpp index e822d4769f..e767047f33 100644 --- a/source/graphics/ModelDef.cpp +++ b/source/graphics/ModelDef.cpp @@ -25,7 +25,6 @@ #include "lib/sysdep/compiler.h" #include "maths/Vector2D.h" #include "ps/FileIo.h" -#include "ps/containers/Span.h" #include "renderer/VertexArray.h" #include diff --git a/source/graphics/ParticleEmitter.cpp b/source/graphics/ParticleEmitter.cpp index edccc50edc..73ec66c4ba 100644 --- a/source/graphics/ParticleEmitter.cpp +++ b/source/graphics/ParticleEmitter.cpp @@ -30,7 +30,6 @@ #include "maths/Matrix3D.h" #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "renderer/Scene.h" #include "renderer/SceneRenderer.h" diff --git a/source/main.cpp b/source/main.cpp index bf05a603fa..547713fe06 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -79,7 +79,6 @@ that of Atlas depending on commandline parameters. #include "ps/UserReport.h" #include "ps/VideoMode.h" #include "ps/XML/Xeromyces.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "rlinterface/RLInterface.h" #include "scriptinterface/JSON.h" @@ -104,6 +103,7 @@ that of Atlas depending on commandline parameters. #include #include #include +#include #include #include #include @@ -553,7 +553,7 @@ static std::optional CreateDAPInterface(const CmdLineArgs& args) // moved into a helper function to ensure args is destroyed before // exit(), which may result in a memory leak. -static void RunGameOrAtlas(const PS::span argv) +static void RunGameOrAtlas(const std::span argv) { const CmdLineArgs args(argv); diff --git a/source/maths/Matrix3D.h b/source/maths/Matrix3D.h index e2db5947d7..514530aa2c 100644 --- a/source/maths/Matrix3D.h +++ b/source/maths/Matrix3D.h @@ -25,9 +25,9 @@ #include "maths/Vector3D.h" #include "maths/Vector4D.h" -#include "ps/containers/Span.h" #include +#include class CQuaternion; @@ -334,7 +334,7 @@ public: CVector3D RotateTransposed(const CVector3D& vector) const; // Returns 16 element array of floats, e.g. for mat4 uniforms. - PS::span AsFloatArray() const + std::span AsFloatArray() const { // Additional check to prevent a weird compiler has a different // alignement for an array and a class members. @@ -344,7 +344,7 @@ public: offsetof(CMatrix3D, _11) == 0 && offsetof(CMatrix3D, _44) == sizeof(float) * 15u, "CMatrix3D should be properly layouted to use AsFloatArray"); - return PS::span(_data, 16); + return std::span(_data, 16); } }; diff --git a/source/maths/Vector2D.h b/source/maths/Vector2D.h index dd118b4a19..e1ea9608b7 100644 --- a/source/maths/Vector2D.h +++ b/source/maths/Vector2D.h @@ -18,10 +18,9 @@ #ifndef INCLUDED_VECTOR2D #define INCLUDED_VECTOR2D -#include "ps/containers/Span.h" - #include #include +#include class CSize2D; @@ -165,7 +164,7 @@ public: void operator-=(const CSize2D& size); // Returns 2 element array of floats, e.g. for vec2 uniforms. - PS::span AsFloatArray() const + std::span AsFloatArray() const { // Additional check to prevent a weird compiler having a different // alignement for an array and a class members. @@ -174,7 +173,7 @@ public: offsetof(CVector2D, X) == 0 && offsetof(CVector2D, Y) == sizeof(float), "Vector2D should be properly layouted to use AsFloatArray"); - return PS::span(&X, 2); + return std::span(&X, 2); } public: diff --git a/source/maths/Vector3D.h b/source/maths/Vector3D.h index 0b8440cda0..b4a8512ef3 100644 --- a/source/maths/Vector3D.h +++ b/source/maths/Vector3D.h @@ -23,9 +23,8 @@ #ifndef INCLUDED_VECTOR3D #define INCLUDED_VECTOR3D -#include "ps/containers/Span.h" - #include +#include class CFixedVector3D; @@ -125,7 +124,7 @@ class CVector3D CVector3D Normalized() const; // Returns 3 element array of floats, e.g. for vec3 uniforms. - PS::span AsFloatArray() const + std::span AsFloatArray() const { // Additional check to prevent a weird compiler has a different // alignement for an array and a class members. @@ -135,7 +134,7 @@ class CVector3D offsetof(CVector3D, Y) == sizeof(float) && offsetof(CVector3D, Z) == sizeof(float) * 2u, "Vector3D should be properly layouted to use AsFloatArray"); - return PS::span(&X, 3); + return std::span(&X, 3); } }; diff --git a/source/maths/Vector4D.h b/source/maths/Vector4D.h index ec8189b041..10ae5572df 100644 --- a/source/maths/Vector4D.h +++ b/source/maths/Vector4D.h @@ -23,9 +23,8 @@ #ifndef INCLUDED_VECTOR4D #define INCLUDED_VECTOR4D -#include "ps/containers/Span.h" - #include +#include class CVector4D { @@ -127,7 +126,7 @@ public: } // Returns 4 element array of floats, e.g. for vec4 uniforms. - PS::span AsFloatArray() const + std::span AsFloatArray() const { // Additional check to prevent a weird compiler has a different // alignement for an array and a class members. @@ -136,7 +135,7 @@ public: offsetof(CVector4D, X) == 0 && offsetof(CVector4D, W) == sizeof(float) * 3u, "CVector4D should be properly layouted to use AsFloatArray"); - return PS::span(&X, 4); + return std::span(&X, 4); } float X, Y, Z, W; diff --git a/source/network/NetEnet.cpp b/source/network/NetEnet.cpp index 8881f6f64e..09256067d0 100644 --- a/source/network/NetEnet.cpp +++ b/source/network/NetEnet.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ #include "NetEnet.h" #include "ps/ConfigDB.h" -#include "ps/containers/Span.h" +#include namespace PS { @@ -49,7 +49,7 @@ ENetHost* CreateHost(const ENetAddress* address, size_t peerCount, size_t channe // Public ENet API doesn't offer a means to change MTU, so do it in a // way least likely to break with ENet updates. host->mtu = g_ConfigDB.Get("network.enetmtu", HOST_DEFAULT_MTU); - for (ENetPeer& p : PS::span{host->peers, host->peerCount}) + for (ENetPeer& p : std::span{host->peers, host->peerCount}) enet_peer_reset(&p); return host; diff --git a/source/ps/GameSetup/CmdLineArgs.cpp b/source/ps/GameSetup/CmdLineArgs.cpp index bbaff6c804..c12c00a159 100644 --- a/source/ps/GameSetup/CmdLineArgs.cpp +++ b/source/ps/GameSetup/CmdLineArgs.cpp @@ -19,7 +19,6 @@ #include "CmdLineArgs.h" #include "lib/sysdep/sysdep.h" -#include "ps/containers/Span.h" #include "scriptinterface/Object.h" #include "scriptinterface/ScriptConversions.h" #include "scriptinterface/ScriptRequest.h" @@ -55,7 +54,7 @@ private: } // namespace -CmdLineArgs::CmdLineArgs(const PS::span argv) +CmdLineArgs::CmdLineArgs(const std::span argv) { if (argv.empty()) return; diff --git a/source/ps/GameSetup/CmdLineArgs.h b/source/ps/GameSetup/CmdLineArgs.h index e76be3c5fd..deaa4b492c 100644 --- a/source/ps/GameSetup/CmdLineArgs.h +++ b/source/ps/GameSetup/CmdLineArgs.h @@ -21,6 +21,7 @@ #include "lib/os_path.h" #include "ps/CStr.h" +#include #include #include @@ -40,7 +41,7 @@ public: * * @param argv span of arguments; argv[0] should be the program's name */ - CmdLineArgs(const PS::span argv); + CmdLineArgs(const std::span argv); /** * Test whether the given name was specified, as either -name or diff --git a/source/ps/GameSetup/tests/test_CmdLineArgs.h b/source/ps/GameSetup/tests/test_CmdLineArgs.h index 53594bbc59..dad3aba817 100644 --- a/source/ps/GameSetup/tests/test_CmdLineArgs.h +++ b/source/ps/GameSetup/tests/test_CmdLineArgs.h @@ -20,10 +20,10 @@ #include "lib/sysdep/os.h" #include "ps/CStr.h" #include "ps/GameSetup/CmdLineArgs.h" -#include "ps/containers/Span.h" #include #include +#include #include class TestCmdLineArgs : public CxxTest::TestSuite @@ -96,7 +96,7 @@ public: CmdLineArgs c(argv); TS_ASSERT_WSTR_EQUALS(c.GetArg0().string(), L"program"); - CmdLineArgs c2(PS::span{}); + CmdLineArgs c2(std::span{}); TS_ASSERT_WSTR_EQUALS(c2.GetArg0().string(), L""); const std::array argv3 = { "ab/cd/ef/gh/../ij" }; diff --git a/source/ps/containers/Span.h b/source/ps/containers/Span.h deleted file mode 100644 index 79e32bbdfe..0000000000 --- a/source/ps/containers/Span.h +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright (C) 2023 Wildfire Games. - * This file is part of 0 A.D. - * - * 0 A.D. is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * 0 A.D. is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with 0 A.D. If not, see . - */ - -#ifndef INCLUDED_PS_SPAN -#define INCLUDED_PS_SPAN - -#include -#include -#include - -namespace PS -{ - -/** - * Simplifed version of std::span (C++20) as we don't support the original one - * yet. The naming intentionally follows the STL version to make the future - * replacement easier with less blame changing. - * It supports only very basic subset of std::span functionality. - * TODO: remove as soon as std::span become available. - */ -template -class span -{ -public: - using element_type = T; - using value_type = std::remove_cv_t; - using size_type = size_t; - using pointer = T*; - using reference = T&; - using iterator = pointer; - - constexpr span() - : m_Pointer(nullptr), m_Extent(0) {} - - constexpr span(iterator first, size_type extent) - : m_Pointer(first), m_Extent(extent) {} - - constexpr span(iterator first, iterator last) - : m_Pointer(first), m_Extent(static_cast(last - first)) {} - - template - constexpr span(const std::array& arr) - : m_Pointer(arr.data()), m_Extent(arr.size()) {} - - template - constexpr span(ContinuousRange& range) - : m_Pointer(range.data()), m_Extent(range.size()) {} - - constexpr span(const span& other) = default; - - constexpr span& operator=(const span& other) = default; - - ~span() = default; - - constexpr size_type size() const { return m_Extent; } - constexpr bool empty() const { return size() == 0; } - constexpr reference operator[](size_type index) const { return *(m_Pointer + index); } - constexpr pointer data() const { return m_Pointer; } - - constexpr iterator begin() const { return m_Pointer; } - constexpr iterator end() const { return m_Pointer + m_Extent; } - - constexpr span subspan(size_type offset) const { return {m_Pointer + offset, m_Extent - offset}; } - -private: - pointer m_Pointer; - size_type m_Extent; -}; - -template -span(const std::array&) -> span; - -} // namespace PS - -#endif // INCLUDED_PS_SPAN diff --git a/source/renderer/CPUSkinnedModelRenderer.cpp b/source/renderer/CPUSkinnedModelRenderer.cpp index b0e9955f7b..013a4aa3ee 100644 --- a/source/renderer/CPUSkinnedModelRenderer.cpp +++ b/source/renderer/CPUSkinnedModelRenderer.cpp @@ -24,7 +24,6 @@ #include "graphics/ModelDef.h" #include "graphics/RenderableObject.h" #include "lib/debug.h" -#include "ps/containers/Span.h" #include "ps/containers/StaticVector.h" #include "renderer/ModelRenderer.h" #include "renderer/Renderer.h" @@ -195,7 +194,7 @@ CModelRData* CPUSkinnedModelVertexRenderer::CreateModelData(const void* key, CMo } void CPUSkinnedModelVertexRenderer::UpdateModelsData(Renderer::Backend::IDeviceCommandContext*, - PS::span models) + std::span models) { for (CModel* model : models) { @@ -226,7 +225,7 @@ void CPUSkinnedModelVertexRenderer::UpdateModelData(CModel* model, CModelRData* void CPUSkinnedModelVertexRenderer::UploadModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) + std::span models) { for (CModel* model : models) { diff --git a/source/renderer/CPUSkinnedModelRenderer.h b/source/renderer/CPUSkinnedModelRenderer.h index b274233fa4..20c4692fbb 100644 --- a/source/renderer/CPUSkinnedModelRenderer.h +++ b/source/renderer/CPUSkinnedModelRenderer.h @@ -21,6 +21,7 @@ #include "renderer/ModelVertexRenderer.h" #include +#include class CModel; class CModelRData; @@ -41,11 +42,11 @@ public: CModelRData* CreateModelData(const void* key, CModel* model) override; void UpdateModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) override; + std::span models) override; void UploadModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) override; + std::span models) override; void PrepareModelDef( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, diff --git a/source/renderer/DebugRenderer.cpp b/source/renderer/DebugRenderer.cpp index 13704353e4..1790f26f3d 100644 --- a/source/renderer/DebugRenderer.cpp +++ b/source/renderer/DebugRenderer.cpp @@ -31,7 +31,6 @@ #include "maths/Matrix3D.h" #include "maths/Vector3D.h" #include "ps/CStrInternStatic.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "renderer/SceneRenderer.h" #include "renderer/backend/Format.h" diff --git a/source/renderer/DecalRData.cpp b/source/renderer/DecalRData.cpp index ea1f6a8774..8d56ed00dd 100644 --- a/source/renderer/DecalRData.cpp +++ b/source/renderer/DecalRData.cpp @@ -39,7 +39,6 @@ #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" #include "ps/Profile.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "renderer/TerrainRenderer.h" #include "renderer/VertexBuffer.h" diff --git a/source/renderer/GPUSkinnedModelRenderer.cpp b/source/renderer/GPUSkinnedModelRenderer.cpp index 89775feafa..75caaa3238 100644 --- a/source/renderer/GPUSkinnedModelRenderer.cpp +++ b/source/renderer/GPUSkinnedModelRenderer.cpp @@ -36,7 +36,6 @@ #include "ps/CLogger.h" #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" -#include "ps/containers/Span.h" #include "ps/containers/StaticVector.h" #include "renderer/ModelRenderer.h" #include "renderer/Renderer.h" @@ -366,7 +365,7 @@ CModelRData* GPUSkinnedModelModelRenderer::CreateModelData(const void* key, CMod void GPUSkinnedModelModelRenderer::UpdateModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) + std::span models) { if (models.empty()) return; @@ -434,7 +433,7 @@ void GPUSkinnedModelModelRenderer::UpdateModelData( // Add 1 to NumBones because of the special 'root' bone. deviceCommandContext->SetUniform( shaderProgram->GetBindingSlot(str_skinBlendMatrices), - PS::span( + std::span( model->GetAnimatedBoneMatrices()[0]._data, model->GetAnimatedBoneMatrices()[0].AsFloatArray().size() * (modelDef->GetNumBones() + 1))); @@ -455,7 +454,7 @@ void GPUSkinnedModelModelRenderer::UpdateModelData( } void GPUSkinnedModelModelRenderer::UploadModelsData(Renderer::Backend::IDeviceCommandContext*, - PS::span) + std::span) { } diff --git a/source/renderer/GPUSkinnedModelRenderer.h b/source/renderer/GPUSkinnedModelRenderer.h index 60f73ca94e..8ae233ef5c 100644 --- a/source/renderer/GPUSkinnedModelRenderer.h +++ b/source/renderer/GPUSkinnedModelRenderer.h @@ -21,6 +21,7 @@ #include "renderer/ModelVertexRenderer.h" #include +#include class CModel; class CModelRData; @@ -43,11 +44,11 @@ public: void UpdateModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) override; + std::span models) override; void UploadModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) override; + std::span models) override; void PrepareModelDef( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, diff --git a/source/renderer/InstancingModelRenderer.cpp b/source/renderer/InstancingModelRenderer.cpp index 9b2d534f94..2799e44977 100644 --- a/source/renderer/InstancingModelRenderer.cpp +++ b/source/renderer/InstancingModelRenderer.cpp @@ -26,7 +26,6 @@ #include "lib/types.h" #include "maths/Vector3D.h" #include "maths/Vector4D.h" -#include "ps/containers/Span.h" #include "ps/containers/StaticVector.h" #include "renderer/ModelRenderer.h" #include "renderer/Renderer.h" @@ -267,13 +266,13 @@ CModelRData* InstancingModelRenderer::CreateModelData(const void* key, CModel* m } void InstancingModelRenderer::UpdateModelsData(Renderer::Backend::IDeviceCommandContext*, - PS::span) + std::span) { // We have no per-CModel data } void InstancingModelRenderer::UploadModelsData(Renderer::Backend::IDeviceCommandContext*, - PS::span) + std::span) { // Data uploaded once during creation as we don't update it dynamically. } diff --git a/source/renderer/InstancingModelRenderer.h b/source/renderer/InstancingModelRenderer.h index 7b44a00f2e..cee149f687 100644 --- a/source/renderer/InstancingModelRenderer.h +++ b/source/renderer/InstancingModelRenderer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -25,6 +25,8 @@ #include "renderer/ModelVertexRenderer.h" +#include + struct InstancingModelRendererInternals; /** @@ -42,11 +44,11 @@ public: CModelRData* CreateModelData(const void* key, CModel* model) override; void UpdateModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) override; + std::span models) override; void UploadModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) override; + std::span models) override; void PrepareModelDef( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, diff --git a/source/renderer/ModelRenderer.cpp b/source/renderer/ModelRenderer.cpp index 38821c1ec5..4a0819a45e 100644 --- a/source/renderer/ModelRenderer.cpp +++ b/source/renderer/ModelRenderer.cpp @@ -42,7 +42,6 @@ #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" #include "ps/Profile.h" -#include "ps/containers/Span.h" #include "renderer/MikktspaceWrap.h" #include "renderer/ModelRenderer.h" #include "renderer/ModelVertexRenderer.h" @@ -60,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -364,7 +364,7 @@ struct SMRMaterialBucketKeyHash struct SMRTechBucket { CShaderTechniquePtr tech; - PS::span models; + std::span models; // Model list is stored as pointers, not as a std::vector, // so that sorting lists of this struct is fast diff --git a/source/renderer/ModelVertexRenderer.h b/source/renderer/ModelVertexRenderer.h index e0d9b360b1..74af34cdfd 100644 --- a/source/renderer/ModelVertexRenderer.h +++ b/source/renderer/ModelVertexRenderer.h @@ -25,10 +25,11 @@ #include "graphics/MeshManager.h" +#include + class CModel; class CModelDef; class CModelRData; -namespace PS { template class span; } namespace Renderer::Backend { class IDeviceCommandContext; } namespace Renderer::Backend { class IShaderProgram; } @@ -84,7 +85,7 @@ public: */ virtual void UpdateModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) = 0; + std::span models) = 0; /** * Upload per-model data to backend. @@ -100,7 +101,7 @@ public: */ virtual void UploadModelsData( Renderer::Backend::IDeviceCommandContext* deviceCommandContext, - PS::span models) = 0; + std::span models) = 0; /** * PrepareModelDef: Setup backend state for rendering of models that diff --git a/source/renderer/OverlayRenderer.cpp b/source/renderer/OverlayRenderer.cpp index b4dbaef463..951848259c 100644 --- a/source/renderer/OverlayRenderer.cpp +++ b/source/renderer/OverlayRenderer.cpp @@ -41,7 +41,6 @@ #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" #include "ps/Profile.h" -#include "ps/containers/Span.h" #include "renderer/DebugRenderer.h" #include "renderer/Renderer.h" #include "renderer/Scene.h" diff --git a/source/renderer/PatchRData.cpp b/source/renderer/PatchRData.cpp index 66566af3dd..579b56d58b 100644 --- a/source/renderer/PatchRData.cpp +++ b/source/renderer/PatchRData.cpp @@ -46,7 +46,6 @@ #include "ps/CStrInternStatic.h" #include "ps/Game.h" #include "ps/Profile.h" -#include "ps/containers/Span.h" #include "renderer/AlphaMapCalculator.h" #include "renderer/BlendShapes.h" #include "renderer/DebugRenderer.h" diff --git a/source/renderer/PostprocManager.cpp b/source/renderer/PostprocManager.cpp index 28dec2ceb8..b2e4204af4 100644 --- a/source/renderer/PostprocManager.cpp +++ b/source/renderer/PostprocManager.cpp @@ -36,7 +36,6 @@ #include "ps/Filesystem.h" #include "ps/Profile.h" #include "ps/World.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "renderer/RenderingOptions.h" #include "renderer/backend/Backend.h" diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index 9378c3bb0e..d47d8f4f39 100644 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -59,7 +59,6 @@ #include "ps/Util.h" #include "ps/VideoMode.h" #include "ps/World.h" -#include "ps/containers/Span.h" #include "renderer/DebugRenderer.h" #include "renderer/ModelRenderer.h" #include "renderer/PostprocManager.h" @@ -923,7 +922,7 @@ Renderer::Backend::IDeviceCommandContext* CRenderer::GetDeviceCommandContext() } Renderer::Backend::IVertexInputLayout* CRenderer::GetVertexInputLayout( - const PS::span attributes) + const std::span attributes) { const auto [it, inserted] = m->vertexInputLayouts.emplace( std::vector{attributes.begin(), attributes.end()}, nullptr); diff --git a/source/renderer/Renderer.h b/source/renderer/Renderer.h index 627212bd38..2bd07945f9 100644 --- a/source/renderer/Renderer.h +++ b/source/renderer/Renderer.h @@ -23,6 +23,7 @@ #include #include +#include class CDebugRenderer; class CFontManager; @@ -32,7 +33,6 @@ class CShaderManager; class CTextureManager; class CTimeManager; class CVertexBufferManager; -namespace PS { template class span; } namespace Renderer::Backend { class IDevice; } namespace Renderer::Backend { class IDeviceCommandContext; } namespace Renderer::Backend { class IVertexInputLayout; } @@ -142,7 +142,7 @@ public: * TODO: we need to make VertexArray less error prone by passing layout. */ Renderer::Backend::IVertexInputLayout* GetVertexInputLayout( - const PS::span attributes); + const std::span attributes); protected: friend class CDecalRData; diff --git a/source/renderer/ShadowMap.cpp b/source/renderer/ShadowMap.cpp index 5f9a9c35d9..ef77b436e9 100644 --- a/source/renderer/ShadowMap.cpp +++ b/source/renderer/ShadowMap.cpp @@ -34,7 +34,6 @@ #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" #include "ps/ConfigDB.h" -#include "ps/containers/Span.h" #include "renderer/DebugRenderer.h" #include "renderer/Renderer.h" #include "renderer/RenderingOptions.h" @@ -54,6 +53,7 @@ #include #include #include +#include #include namespace @@ -694,12 +694,12 @@ void ShadowMap::BindTo( } deviceCommandContext->SetUniform( shader->GetBindingSlot(str_shadowTransform), - PS::span( + std::span( shadowTransforms[0]._data, shadowTransforms[0].AsFloatArray().size() * GetCascadeCount())); deviceCommandContext->SetUniform( shader->GetBindingSlot(str_shadowDistance), - PS::span(shadowDistances.data(), shadowDistances.size())); + std::span(shadowDistances.data(), shadowDistances.size())); } } diff --git a/source/renderer/SilhouetteRenderer.cpp b/source/renderer/SilhouetteRenderer.cpp index 9e6394f3a8..dffc18e41f 100644 --- a/source/renderer/SilhouetteRenderer.cpp +++ b/source/renderer/SilhouetteRenderer.cpp @@ -38,7 +38,6 @@ #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" #include "ps/Profile.h" -#include "ps/containers/Span.h" #include "renderer/DebugRenderer.h" #include "renderer/Renderer.h" #include "renderer/Scene.h" diff --git a/source/renderer/SkyManager.cpp b/source/renderer/SkyManager.cpp index 124a7a02ff..235491a735 100644 --- a/source/renderer/SkyManager.cpp +++ b/source/renderer/SkyManager.cpp @@ -42,7 +42,6 @@ #include "ps/CStrInternStatic.h" #include "ps/ConfigDB.h" #include "ps/Filesystem.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "renderer/SceneRenderer.h" #include "renderer/backend/Format.h" diff --git a/source/renderer/TerrainOverlay.cpp b/source/renderer/TerrainOverlay.cpp index 61034959e2..0418490959 100644 --- a/source/renderer/TerrainOverlay.cpp +++ b/source/renderer/TerrainOverlay.cpp @@ -36,7 +36,6 @@ #include "ps/Game.h" #include "ps/Profile.h" #include "ps/World.h" -#include "ps/containers/Span.h" #include "renderer/Renderer.h" #include "renderer/SceneRenderer.h" #include "renderer/TerrainRenderer.h" diff --git a/source/renderer/TerrainRenderer.cpp b/source/renderer/TerrainRenderer.cpp index b4770fdfee..7823bc5da4 100644 --- a/source/renderer/TerrainRenderer.cpp +++ b/source/renderer/TerrainRenderer.cpp @@ -42,7 +42,6 @@ #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" #include "ps/Profile.h" -#include "ps/containers/Span.h" #include "renderer/DecalRData.h" #include "renderer/PatchRData.h" #include "renderer/PostprocManager.h" diff --git a/source/renderer/TexturedLineRData.cpp b/source/renderer/TexturedLineRData.cpp index fd87fbe8d9..35dc50a5a9 100644 --- a/source/renderer/TexturedLineRData.cpp +++ b/source/renderer/TexturedLineRData.cpp @@ -28,7 +28,6 @@ #include "maths/Quaternion.h" #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" -#include "ps/containers/Span.h" #include "renderer/OverlayRenderer.h" #include "renderer/Renderer.h" #include "renderer/VertexBuffer.h" diff --git a/source/renderer/WaterManager.cpp b/source/renderer/WaterManager.cpp index 0bbfc49118..1bfde5480f 100644 --- a/source/renderer/WaterManager.cpp +++ b/source/renderer/WaterManager.cpp @@ -39,7 +39,6 @@ #include "ps/CStrInternStatic.h" #include "ps/Game.h" #include "ps/World.h" -#include "ps/containers/Span.h" #include "renderer/PostprocManager.h" #include "renderer/Renderer.h" #include "renderer/RenderingOptions.h" diff --git a/source/renderer/backend/IDevice.h b/source/renderer/backend/IDevice.h index 0a3652ebd2..5862920d1c 100644 --- a/source/renderer/backend/IDevice.h +++ b/source/renderer/backend/IDevice.h @@ -26,13 +26,13 @@ #include #include #include +#include #include #include class CShaderDefines; class CStr; class ScriptRequest; -namespace PS { template class span; } namespace Renderer::Backend { class IComputePipelineState; } namespace Renderer::Backend { class IDeviceCommandContext; } namespace Renderer::Backend { class IFramebuffer; } @@ -109,7 +109,7 @@ public: * layouts as posible. */ virtual std::unique_ptr CreateVertexInputLayout( - const PS::span attributes) = 0; + const std::span attributes) = 0; virtual std::unique_ptr CreateTexture( const char* name, const ITexture::Type type, const uint32_t usage, diff --git a/source/renderer/backend/IDeviceCommandContext.h b/source/renderer/backend/IDeviceCommandContext.h index f1db34b4a3..bfd6136890 100644 --- a/source/renderer/backend/IDeviceCommandContext.h +++ b/source/renderer/backend/IDeviceCommandContext.h @@ -21,11 +21,12 @@ #include "lib/types.h" #include "renderer/backend/IDeviceObject.h" + #include #include #include +#include -namespace PS { template class span; } namespace Renderer::Backend { class IComputePipelineState; } namespace Renderer::Backend { class IGraphicsPipelineState; } namespace Renderer::Backend { class IVertexInputLayout; } @@ -223,7 +224,7 @@ public: const float valueX, const float valueY, const float valueZ, const float valueW) = 0; virtual void SetUniform( - const int32_t bindingSlot, PS::span values) = 0; + const int32_t bindingSlot, std::span values) = 0; /** * Insert a timestamp query which can be later requested via IDevice. diff --git a/source/renderer/backend/dummy/Device.cpp b/source/renderer/backend/dummy/Device.cpp index 67d508626b..ba19c2fccd 100644 --- a/source/renderer/backend/dummy/Device.cpp +++ b/source/renderer/backend/dummy/Device.cpp @@ -19,7 +19,6 @@ #include "Device.h" -#include "ps/containers/Span.h" #include "renderer/backend/Format.h" #include "renderer/backend/IFramebuffer.h" #include "renderer/backend/dummy/Buffer.h" @@ -90,7 +89,7 @@ std::unique_ptr CDevice::CreateComputePipelineState( } std::unique_ptr CDevice::CreateVertexInputLayout( - const PS::span) + const std::span) { return nullptr; } diff --git a/source/renderer/backend/dummy/Device.h b/source/renderer/backend/dummy/Device.h index 3278a1d10f..a46acd706f 100644 --- a/source/renderer/backend/dummy/Device.h +++ b/source/renderer/backend/dummy/Device.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -65,7 +66,7 @@ public: const SComputePipelineStateDesc& pipelineStateDesc) override; std::unique_ptr CreateVertexInputLayout( - const PS::span attributes) override; + const std::span attributes) override; std::unique_ptr CreateTexture( const char* name, const ITexture::Type type, const uint32_t usage, diff --git a/source/renderer/backend/dummy/DeviceCommandContext.cpp b/source/renderer/backend/dummy/DeviceCommandContext.cpp index ca03b13d91..475021341e 100644 --- a/source/renderer/backend/dummy/DeviceCommandContext.cpp +++ b/source/renderer/backend/dummy/DeviceCommandContext.cpp @@ -19,7 +19,6 @@ #include "DeviceCommandContext.h" -#include "ps/containers/Span.h" #include "renderer/backend/dummy/Device.h" namespace Renderer @@ -238,7 +237,7 @@ void CDeviceCommandContext::SetUniform( { } -void CDeviceCommandContext::SetUniform(const int32_t, PS::span) +void CDeviceCommandContext::SetUniform(const int32_t, std::span) { } diff --git a/source/renderer/backend/dummy/DeviceCommandContext.h b/source/renderer/backend/dummy/DeviceCommandContext.h index 864bc1033f..0db72043d0 100644 --- a/source/renderer/backend/dummy/DeviceCommandContext.h +++ b/source/renderer/backend/dummy/DeviceCommandContext.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace Renderer::Backend::Dummy { class CDevice; } @@ -142,7 +143,7 @@ public: const float valueX, const float valueY, const float valueZ, const float valueW) override; void SetUniform( - const int32_t bindingSlot, PS::span values) override; + const int32_t bindingSlot, std::span values) override; void InsertTimestampQuery(const uint32_t handle, const bool isScopeBegin) override; diff --git a/source/renderer/backend/gl/Device.cpp b/source/renderer/backend/gl/Device.cpp index acafeabbc8..8389a0bc0a 100644 --- a/source/renderer/backend/gl/Device.cpp +++ b/source/renderer/backend/gl/Device.cpp @@ -31,7 +31,6 @@ #include "ps/CLogger.h" #include "ps/ConfigDB.h" #include "ps/Profile.h" -#include "ps/containers/Span.h" #include "renderer/backend/Format.h" #include "renderer/backend/gl/Buffer.h" #include "renderer/backend/gl/DeviceCommandContext.h" @@ -919,7 +918,7 @@ std::unique_ptr CDevice::CreateComputePipelineState( } std::unique_ptr CDevice::CreateVertexInputLayout( - const PS::span attributes) + const std::span attributes) { return std::make_unique(this, attributes); } diff --git a/source/renderer/backend/gl/Device.h b/source/renderer/backend/gl/Device.h index cc079d0dab..01e1c03dc8 100644 --- a/source/renderer/backend/gl/Device.h +++ b/source/renderer/backend/gl/Device.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -79,7 +80,7 @@ public: const SComputePipelineStateDesc& pipelineStateDesc) override; std::unique_ptr CreateVertexInputLayout( - const PS::span attributes) override; + const std::span attributes) override; CDeviceCommandContext* GetActiveCommandContext() { return m_ActiveCommandContext; } diff --git a/source/renderer/backend/gl/DeviceCommandContext.cpp b/source/renderer/backend/gl/DeviceCommandContext.cpp index 4dd0bec378..924603027c 100644 --- a/source/renderer/backend/gl/DeviceCommandContext.cpp +++ b/source/renderer/backend/gl/DeviceCommandContext.cpp @@ -22,7 +22,6 @@ #include "lib/config2.h" #include "lib/debug.h" #include "ps/CLogger.h" -#include "ps/containers/Span.h" #include "renderer/backend/Barrier.h" #include "renderer/backend/Format.h" #include "renderer/backend/IFramebuffer.h" @@ -1421,7 +1420,7 @@ void CDeviceCommandContext::SetUniform( } void CDeviceCommandContext::SetUniform( - const int32_t bindingSlot, PS::span values) + const int32_t bindingSlot, std::span values) { ENSURE(m_ShaderProgram); m_ShaderProgram->SetUniform(bindingSlot, values); diff --git a/source/renderer/backend/gl/DeviceCommandContext.h b/source/renderer/backend/gl/DeviceCommandContext.h index 415453c260..9bb9ebdb35 100644 --- a/source/renderer/backend/gl/DeviceCommandContext.h +++ b/source/renderer/backend/gl/DeviceCommandContext.h @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace Renderer::Backend { enum class Format; } @@ -157,7 +158,7 @@ public: const float valueX, const float valueY, const float valueZ, const float valueW) override; void SetUniform( - const int32_t bindingSlot, PS::span values) override; + const int32_t bindingSlot, std::span values) override; void InsertTimestampQuery(const uint32_t handle, const bool isScopeBegin) override; diff --git a/source/renderer/backend/gl/ShaderProgram.cpp b/source/renderer/backend/gl/ShaderProgram.cpp index d67e879118..30551fcd0d 100644 --- a/source/renderer/backend/gl/ShaderProgram.cpp +++ b/source/renderer/backend/gl/ShaderProgram.cpp @@ -531,7 +531,7 @@ public: } void SetUniform( - const int32_t bindingSlot, PS::span values) override + const int32_t bindingSlot, std::span values) override { if (bindingSlot < 0 || bindingSlot >= static_cast(m_BindingSlots.size())) return; @@ -619,7 +619,7 @@ private: } void SetUniformMatrix( - const BindingSlot& bindingSlot, PS::span values) + const BindingSlot& bindingSlot, std::span values) { const size_t mat4ElementCount = 16; ENSURE(values.size() == mat4ElementCount); @@ -628,7 +628,7 @@ private: } void SetUniformMatrix( - const GLenum target, const int location, PS::span values) + const GLenum target, const int location, std::span values) { if (location >= 0) { @@ -661,7 +661,7 @@ class CShaderProgramGLSL final : public CShaderProgram public: CShaderProgramGLSL( CDevice* device, const CStr& name, - const VfsPath& programPath, PS::span> shaderStages, + const VfsPath& programPath, std::span> shaderStages, const CShaderDefines& defines, const std::map& vertexAttribs, int streamflags) : @@ -1201,7 +1201,7 @@ public: } void SetUniform( - const int32_t bindingSlot, PS::span values) override + const int32_t bindingSlot, std::span values) override { if (bindingSlot < 0 || bindingSlot >= static_cast(m_BindingSlots.size())) return; diff --git a/source/renderer/backend/gl/ShaderProgram.h b/source/renderer/backend/gl/ShaderProgram.h index 26d518977c..eae1ca4c9f 100644 --- a/source/renderer/backend/gl/ShaderProgram.h +++ b/source/renderer/backend/gl/ShaderProgram.h @@ -22,12 +22,12 @@ #include "lib/debug.h" #include "lib/ogl.h" #include "ps/CStr.h" -#include "ps/containers/Span.h" #include "renderer/backend/Format.h" #include "renderer/backend/IShaderProgram.h" #include #include +#include #include class CShaderDefines; @@ -46,7 +46,7 @@ namespace GL class CVertexInputLayout : public IVertexInputLayout { public: - CVertexInputLayout(CDevice* device, const PS::span attributes) + CVertexInputLayout(CDevice* device, const std::span attributes) : m_Device(device), m_Attributes(attributes.begin(), attributes.end()) { for (const SVertexAttributeFormat& attribute : m_Attributes) @@ -130,7 +130,7 @@ public: const float valueX, const float valueY, const float valueZ, const float valueW) = 0; virtual void SetUniform( - const int32_t bindingSlot, PS::span values) = 0; + const int32_t bindingSlot, std::span values) = 0; // Vertex attribute pointers (equivalent to glVertexPointer etc). virtual void VertexAttribPointer( diff --git a/source/renderer/backend/gl/Texture.cpp b/source/renderer/backend/gl/Texture.cpp index fd674dc910..19c9e5980a 100644 --- a/source/renderer/backend/gl/Texture.cpp +++ b/source/renderer/backend/gl/Texture.cpp @@ -22,7 +22,6 @@ #include "graphics/Color.h" #include "lib/config2.h" #include "lib/debug.h" -#include "ps/containers/Span.h" #include "renderer/backend/Sampler.h" #include "renderer/backend/gl/Device.h" #include "renderer/backend/gl/DeviceCommandContext.h" diff --git a/source/renderer/backend/vulkan/Device.cpp b/source/renderer/backend/vulkan/Device.cpp index d2c7b66220..759dd07f37 100644 --- a/source/renderer/backend/vulkan/Device.cpp +++ b/source/renderer/backend/vulkan/Device.cpp @@ -25,7 +25,6 @@ #include "ps/CLogger.h" #include "ps/ConfigDB.h" #include "ps/Profile.h" -#include "ps/containers/Span.h" #include "ps/containers/StaticVector.h" #include "renderer/backend/Format.h" #include "renderer/backend/vulkan/Buffer.h" @@ -747,7 +746,7 @@ std::unique_ptr CDevice::CreateComputePipelineState( } std::unique_ptr CDevice::CreateVertexInputLayout( - const PS::span attributes) + const std::span attributes) { return std::make_unique(this, attributes); } diff --git a/source/renderer/backend/vulkan/Device.h b/source/renderer/backend/vulkan/Device.h index 4c855238cb..0f43d2f228 100644 --- a/source/renderer/backend/vulkan/Device.h +++ b/source/renderer/backend/vulkan/Device.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -90,7 +91,7 @@ public: const SComputePipelineStateDesc& pipelineStateDesc) override; std::unique_ptr CreateVertexInputLayout( - const PS::span attributes) override; + const std::span attributes) override; std::unique_ptr CreateTexture( const char* name, const ITexture::Type type, const uint32_t usage, diff --git a/source/renderer/backend/vulkan/DeviceCommandContext.cpp b/source/renderer/backend/vulkan/DeviceCommandContext.cpp index d20f7edd61..1762e3092a 100644 --- a/source/renderer/backend/vulkan/DeviceCommandContext.cpp +++ b/source/renderer/backend/vulkan/DeviceCommandContext.cpp @@ -24,7 +24,6 @@ #include "lib/debug.h" #include "ps/CLogger.h" #include "ps/ConfigDB.h" -#include "ps/containers/Span.h" #include "ps/containers/StaticVector.h" #include "renderer/backend/Format.h" #include "renderer/backend/IBuffer.h" @@ -112,7 +111,7 @@ class ScopedImageLayoutTransition { public: ScopedImageLayoutTransition( - CRingCommandContext& commandContext, const PS::span textures, + CRingCommandContext& commandContext, const std::span textures, const VkImageLayout layout, const VkAccessFlags accessMask, const VkPipelineStageFlags stageMask) : m_CommandContext(commandContext), m_Textures(textures), m_Layout(layout), m_AccessMask(accessMask), m_StageMask(stageMask) @@ -147,7 +146,7 @@ public: private: CRingCommandContext& m_CommandContext; - const PS::span m_Textures; + const std::span m_Textures; const VkImageLayout m_Layout = VK_IMAGE_LAYOUT_UNDEFINED; const VkAccessFlags m_AccessMask = 0; const VkPipelineStageFlags m_StageMask = 0; @@ -215,7 +214,7 @@ public: CBuffer* GetBuffer() { return m_Buffer.get(); } uint32_t ScheduleUpload( - VkCommandBuffer commandBuffer, const PS::span data, + VkCommandBuffer commandBuffer, const std::span data, const uint32_t alignment); void ExecuteUploads(VkCommandBuffer commandBuffer); @@ -271,7 +270,7 @@ void CDeviceCommandContext::CUploadRing::ResizeIfNeeded( } uint32_t CDeviceCommandContext::CUploadRing::ScheduleUpload( - VkCommandBuffer commandBuffer, const PS::span data, + VkCommandBuffer commandBuffer, const std::span data, const uint32_t alignment) { ENSURE(data.size() > 0); @@ -820,7 +819,7 @@ void CDeviceCommandContext::SetVertexBufferData( const uint32_t offset = m_VertexUploadRing->ScheduleUpload( m_PrependCommandContext->GetCommandBuffer(), - PS::span{static_cast(data), dataSize}, ALIGNMENT); + std::span{static_cast(data), dataSize}, ALIGNMENT); BindVertexBuffer(bindingSlot, m_VertexUploadRing->GetBuffer(), offset); } @@ -837,7 +836,7 @@ void CDeviceCommandContext::SetIndexBufferData( const uint32_t offset = m_IndexUploadRing->ScheduleUpload( m_PrependCommandContext->GetCommandBuffer(), - PS::span{static_cast(data), dataSize}, ALIGNMENT); + std::span{static_cast(data), dataSize}, ALIGNMENT); BindIndexBuffer(m_IndexUploadRing->GetBuffer(), offset); } @@ -1017,7 +1016,7 @@ void CDeviceCommandContext::SetUniform( } void CDeviceCommandContext::SetUniform( - const int32_t bindingSlot, PS::span values) + const int32_t bindingSlot, std::span values) { ENSURE(m_InsidePass || m_InsideComputePass); m_ShaderProgram->SetUniform(bindingSlot, values); @@ -1158,7 +1157,7 @@ void CDeviceCommandContext::UpdateOutdatedConstants() std::max(static_cast(16), m_Device->GetChoosenPhysicalDevice().properties.limits.minUniformBufferOffsetAlignment); const uint32_t offset = m_UniformUploadRing->ScheduleUpload( m_PrependCommandContext->GetCommandBuffer(), - PS::span{ + std::span{ m_ShaderProgram->GetMaterialConstantsData(), m_ShaderProgram->GetMaterialConstantsDataSize()}, alignment); m_ShaderProgram->UpdateMaterialConstantsData(); diff --git a/source/renderer/backend/vulkan/DeviceCommandContext.h b/source/renderer/backend/vulkan/DeviceCommandContext.h index 9c5a5ea3e3..745530a4c0 100644 --- a/source/renderer/backend/vulkan/DeviceCommandContext.h +++ b/source/renderer/backend/vulkan/DeviceCommandContext.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace Renderer { @@ -149,7 +150,7 @@ public: const float valueX, const float valueY, const float valueZ, const float valueW) override; void SetUniform( - const int32_t bindingSlot, PS::span values) override; + const int32_t bindingSlot, std::span values) override; void InsertTimestampQuery(const uint32_t handle, const bool isScopeBegin) override; diff --git a/source/renderer/backend/vulkan/ShaderProgram.cpp b/source/renderer/backend/vulkan/ShaderProgram.cpp index 4233296c05..3ca68e51c4 100644 --- a/source/renderer/backend/vulkan/ShaderProgram.cpp +++ b/source/renderer/backend/vulkan/ShaderProgram.cpp @@ -793,7 +793,7 @@ void CShaderProgram::SetUniform( const float value) { const float values[1] = {value}; - SetUniform(bindingSlot, PS::span(values, values + 1)); + SetUniform(bindingSlot, std::span(values, values + 1)); } void CShaderProgram::SetUniform( @@ -801,7 +801,7 @@ void CShaderProgram::SetUniform( const float valueX, const float valueY) { const float values[2] = {valueX, valueY}; - SetUniform(bindingSlot, PS::span(values, values + 2)); + SetUniform(bindingSlot, std::span(values, values + 2)); } void CShaderProgram::SetUniform( @@ -810,7 +810,7 @@ void CShaderProgram::SetUniform( const float valueZ) { const float values[3] = {valueX, valueY, valueZ}; - SetUniform(bindingSlot, PS::span(values, values + 3)); + SetUniform(bindingSlot, std::span(values, values + 3)); } void CShaderProgram::SetUniform( @@ -819,10 +819,10 @@ void CShaderProgram::SetUniform( const float valueZ, const float valueW) { const float values[4] = {valueX, valueY, valueZ, valueW}; - SetUniform(bindingSlot, PS::span(values, values + 4)); + SetUniform(bindingSlot, std::span(values, values + 4)); } -void CShaderProgram::SetUniform(const int32_t bindingSlot, PS::span values) +void CShaderProgram::SetUniform(const int32_t bindingSlot, std::span values) { if (bindingSlot < 0) return; diff --git a/source/renderer/backend/vulkan/ShaderProgram.h b/source/renderer/backend/vulkan/ShaderProgram.h index 3718bd36b4..b7db793d3a 100644 --- a/source/renderer/backend/vulkan/ShaderProgram.h +++ b/source/renderer/backend/vulkan/ShaderProgram.h @@ -22,7 +22,6 @@ #include "lib/file/vfs/vfs_path.h" #include "ps/CStr.h" #include "ps/CStrIntern.h" -#include "ps/containers/Span.h" #include "renderer/backend/Format.h" #include "renderer/backend/IShaderProgram.h" #include "renderer/backend/vulkan/DescriptorManager.h" @@ -33,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +56,7 @@ namespace Vulkan class CVertexInputLayout : public IVertexInputLayout { public: - CVertexInputLayout(CDevice* device, const PS::span attributes) + CVertexInputLayout(CDevice* device, const std::span attributes) : m_Device(device), m_Attributes(attributes.begin(), attributes.end()) { static uint32_t m_LastAvailableUID = 1; @@ -125,7 +125,7 @@ public: const float valueX, const float valueY, const float valueZ, const float valueW); void SetUniform( - const int32_t bindingSlot, PS::span values); + const int32_t bindingSlot, std::span values); void SetTexture(const int32_t bindingSlot, CTexture* texture); void SetStorageTexture(const int32_t bindingSlot, CTexture* texture); diff --git a/source/soundmanager/data/OggData.cpp b/source/soundmanager/data/OggData.cpp index eacd43df27..4d960eaf39 100644 --- a/source/soundmanager/data/OggData.cpp +++ b/source/soundmanager/data/OggData.cpp @@ -25,12 +25,12 @@ #include "lib/types.h" #include "ps/CLogger.h" #include "ps/Filesystem.h" -#include "ps/containers/Span.h" #include "soundmanager/SoundManager.h" #include "soundmanager/data/ogg.h" #include #include +#include #include /* @@ -128,7 +128,7 @@ int COggData::FetchDataIntoBuffer(int count, ALuint* buffers) for (int i{0}; i < count && !m_FileFinished; ++i) { std::fill(PCMOut.begin(), PCMOut.end(), 0); - const size_t totalRet{m_Stream->GetNextChunk(PS::span(PCMOut))}; + const size_t totalRet{m_Stream->GetNextChunk(std::span(PCMOut))}; m_FileFinished = m_Stream->AtFileEOF(); if (totalRet == 0) continue; diff --git a/source/soundmanager/data/ogg.cpp b/source/soundmanager/data/ogg.cpp index 858954ba17..adf996f390 100644 --- a/source/soundmanager/data/ogg.cpp +++ b/source/soundmanager/data/ogg.cpp @@ -27,7 +27,6 @@ #include "lib/posix/posix_types.h" #include "maths/MathUtil.h" #include "ps/CLogger.h" -#include "ps/containers/Span.h" #include #include @@ -187,7 +186,7 @@ public: return INFO::OK; } - virtual size_t GetNextChunk(PS::span buffer) + virtual size_t GetNextChunk(std::span buffer) { // We may have to call ov_read multiple times because it // treats the buffer size "as a limit and not a request". diff --git a/source/soundmanager/data/ogg.h b/source/soundmanager/data/ogg.h index 0fd3b1563f..83b41ac6cf 100644 --- a/source/soundmanager/data/ogg.h +++ b/source/soundmanager/data/ogg.h @@ -29,8 +29,7 @@ #include #include #include - -namespace PS { template class span; } +#include class OggStream { @@ -41,7 +40,7 @@ public: virtual bool AtFileEOF() = 0; virtual Status ResetFile() = 0; - virtual size_t GetNextChunk(PS::span buffer) = 0; + virtual size_t GetNextChunk(std::span buffer) = 0; }; using OggStreamPtr = std::shared_ptr; diff --git a/source/soundmanager/items/CSoundBase.cpp b/source/soundmanager/items/CSoundBase.cpp index 73bdb43479..3bf47f57d7 100644 --- a/source/soundmanager/items/CSoundBase.cpp +++ b/source/soundmanager/items/CSoundBase.cpp @@ -24,7 +24,6 @@ #include "lib/path.h" #include "lib/timer.h" #include "maths/Vector3D.h" -#include "ps/containers/Span.h" #include "soundmanager/ISoundManager.h" #include "soundmanager/SoundManager.h" #include "soundmanager/data/SoundData.h"