Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions OloEditor/src/MCP/McpToolsRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ namespace OloEngine::MCP
if (RenderOverrides::IsVirtualGeometryView(view))
{
r.CaptureTarget = "VirtualGeometryDebug";
r.PassEnabled = deferred && virtualRegistry.GetDebugColorTextureID() != 0;
r.PassEnabled = deferred && virtualRegistry.GetDebugColorTexture().IsValid();
if (!deferred)
r.Note = "Virtual geometry renders on the DEFERRED path only (current path: " +
std::string(RenderingPathName(Renderer3D::GetRendererSettings().Path)) +
Expand Down Expand Up @@ -2284,7 +2284,10 @@ namespace OloEngine::MCP
bool liveFrame = false;
for (const auto& acquired : pool.GetAcquireOrder(&liveFrame))
{
Json a{ { "kind", acquired.Kind }, { "glId", acquired.RendererID } };
Json a{ { "kind", acquired.Kind },
{ "glId", acquired.RendererID },
{ "identityIndex", acquired.Handle.Index },
{ "identityGeneration", acquired.Handle.Generation } };
if (acquired.Kind == "buffer")
a["sizeBytes"] = acquired.SizeBytes;
else
Expand Down Expand Up @@ -3943,7 +3946,7 @@ namespace OloEngine::MCP
j["swRasterMode"] = VirtualSwRasterModeToken(registry.GetSwRasterMode());
j["swRasterThresholdPixels"] = registry.GetSwRasterThresholdPixels();
j["forcePortableSwRaster"] = registry.GetForcePortableSwRaster();
j["debugTargetAvailable"] = registry.GetDebugColorTextureID() != 0;
j["debugTargetAvailable"] = registry.GetDebugColorTexture().IsValid();
return j;
}

Expand Down Expand Up @@ -4637,10 +4640,13 @@ namespace OloEngine::MCP
"slice was sampled.";
}

probe.Raw = ProbeVolumeTexel(state.ScatterTextureID, "scatter", probe.Coord.IX, probe.Coord.IY,
probe.Coord.IZ);
probe.Integrated = ProbeVolumeTexel(state.IntegratedTextureID, "integrated", probe.Coord.IX,
probe.Coord.IY, probe.Coord.IZ);
// The fog volumes are identities now (issue #691 step 3, item 4); this
// probe reads them back with raw GL, which is the sanctioned use of the
// diagnostics hatch.
probe.Raw = ProbeVolumeTexel(Debug::NativeTextureIdForDiagnostics(state.ScatterTextureID),
"scatter", probe.Coord.IX, probe.Coord.IY, probe.Coord.IZ);
probe.Integrated = ProbeVolumeTexel(Debug::NativeTextureIdForDiagnostics(state.IntegratedTextureID),
"integrated", probe.Coord.IX, probe.Coord.IY, probe.Coord.IZ);

Json j = FroxelFog::ToJson(probe);
j["fog"] = Json{ { "enabled", fog.Enabled },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ namespace OloEngine
}

void MorphTargetEvaluator::EvaluateGPU(
u32 baseVertexSSBO,
u32 morphDeltaSSBO,
u32 weightsSSBO,
u32 outputVertexSSBO,
RHI::ResourceHandle baseVertexSSBO,
RHI::ResourceHandle morphDeltaSSBO,
RHI::ResourceHandle weightsSSBO,
RHI::ResourceHandle outputVertexSSBO,
u32 vertexCount,
[[maybe_unused]] u32 targetCount)
{
Expand Down Expand Up @@ -108,9 +108,9 @@ namespace OloEngine
RenderCommand::MemoryBarrier(MemoryBarrierFlags::ShaderStorage);

// Unbind SSBOs
RenderCommand::BindStorageBuffer(0, 0);
RenderCommand::BindStorageBuffer(1, 0);
RenderCommand::BindStorageBuffer(2, 0);
RenderCommand::BindStorageBuffer(3, 0);
RenderCommand::BindStorageBuffer(0, RHI::NullResource);
RenderCommand::BindStorageBuffer(1, RHI::NullResource);
RenderCommand::BindStorageBuffer(2, RHI::NullResource);
RenderCommand::BindStorageBuffer(3, RHI::NullResource);
}
} // namespace OloEngine
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "OloEngine/Renderer/RHI/RHITypes.h"
#include "MorphTargetSet.h"
#include "OloEngine/Core/Base.h"

Expand All @@ -22,10 +23,10 @@ namespace OloEngine

// GPU path: compute shader evaluation
static void EvaluateGPU(
u32 baseVertexSSBO,
u32 morphDeltaSSBO,
u32 weightsSSBO,
u32 outputVertexSSBO,
RHI::ResourceHandle baseVertexSSBO,
RHI::ResourceHandle morphDeltaSSBO,
RHI::ResourceHandle weightsSSBO,
RHI::ResourceHandle outputVertexSSBO,
u32 vertexCount,
u32 targetCount);
};
Expand Down
17 changes: 9 additions & 8 deletions OloEngine/src/OloEngine/Particle/ParticleBatchRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,11 @@ namespace OloEngine
}

// Bind textures for particle rendering (slot 0 = diffuse, slot 1 = depth for soft particles)
static void BindParticleTextures(bool hasTexture, u32 textureID)
static void BindParticleTextures(bool hasTexture, RHI::ResourceHandle texture)
{
RenderCommand::BindTexture(0, hasTexture ? textureID : s_Data.WhiteTexture->GetRendererID());
RenderCommand::BindTexture(1, s_Data.SoftParams.Enabled ? s_Data.SoftParams.DepthTextureID : s_Data.WhiteTexture->GetRendererID());
RenderCommand::BindTexture(0, hasTexture ? texture : s_Data.WhiteTexture->GetRHIHandle());
RenderCommand::BindTexture(1, s_Data.SoftParams.Enabled ? s_Data.SoftParams.DepthTextureID
: s_Data.WhiteTexture->GetRHIHandle());
}

void ParticleBatchRenderer::EndBatch()
Expand Down Expand Up @@ -412,7 +413,7 @@ namespace OloEngine
activeShader->Bind();

// Bind textures
BindParticleTextures(hasTexture, hasTexture ? s_Data.CurrentTexture->GetRendererID() : 0);
BindParticleTextures(hasTexture, hasTexture ? s_Data.CurrentTexture->GetRHIHandle() : RHI::NullResource);

// Instanced draw call
RenderCommand::DrawIndexedInstanced(s_Data.VAO, 6, s_Data.InstanceCount);
Expand Down Expand Up @@ -448,7 +449,7 @@ namespace OloEngine
s_Data.MeshParticleShader->Bind();

// Bind textures
BindParticleTextures(hasTexture, hasTexture ? texture->GetRendererID() : 0);
BindParticleTextures(hasTexture, hasTexture ? texture->GetRHIHandle() : RHI::NullResource);

auto vao = mesh->GetVertexArray();
u32 indexCount = mesh->GetIndexCount();
Expand Down Expand Up @@ -529,7 +530,7 @@ namespace OloEngine
s_Data.TrailShader->Bind();

// Bind textures
BindParticleTextures(hasTexture, hasTexture ? s_Data.CurrentTrailTexture->GetRendererID() : 0);
BindParticleTextures(hasTexture, hasTexture ? s_Data.CurrentTrailTexture->GetRHIHandle() : RHI::NullResource);

// Draw trail quads
u32 indexCount = s_Data.TrailQuadCount * 6;
Expand Down Expand Up @@ -563,10 +564,10 @@ namespace OloEngine
gpuSystem.GetPrevPositionSSBO()->Bind();

// Bind textures
BindParticleTextures(hasTexture, hasTexture ? texture->GetRendererID() : 0);
BindParticleTextures(hasTexture, hasTexture ? texture->GetRHIHandle() : RHI::NullResource);

// Indirect draw using the GPU-dedicated VAO (no instance attributes)
RenderCommand::DrawElementsIndirect(s_Data.GPUVAO, gpuSystem.GetIndirectDrawSSBO()->GetRendererID());
RenderCommand::DrawElementsIndirect(s_Data.GPUVAO, gpuSystem.GetIndirectDrawSSBO()->GetRHIHandle());

++s_Data.Stats.DrawCalls;
// InstanceCount not updated here: GetAliveCount() requires a GPU→CPU readback that would stall the pipeline
Expand Down
3 changes: 2 additions & 1 deletion OloEngine/src/OloEngine/Particle/ParticleBatchRenderer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "OloEngine/Renderer/RHI/RHITypes.h"
#include "OloEngine/Core/Base.h"
#include "OloEngine/Renderer/Camera/EditorCamera.h"
#include "OloEngine/Renderer/Camera/Camera.h"
Expand Down Expand Up @@ -52,7 +53,7 @@ namespace OloEngine
{
bool Enabled = false;
f32 Distance = 1.0f;
u32 DepthTextureID = 0;
RHI::ResourceHandle DepthTextureID{};
f32 NearClip = 0.1f;
f32 FarClip = 1000.0f;
glm::vec2 ViewportSize = { 1280.0f, 720.0f };
Expand Down
6 changes: 3 additions & 3 deletions OloEngine/src/OloEngine/Precipitation/PrecipitationSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ namespace OloEngine
{
OLO_PROFILE_FUNCTION();

if (s_Data.m_TimerQueries[0] != 0)
if (s_Data.m_TimerQueries[0].IsValid())
{
RenderCommand::DeleteQueries(s_Data.m_TimerQueries);
s_Data.m_TimerQueries[0] = 0;
s_Data.m_TimerQueries[1] = 0;
s_Data.m_TimerQueries[0] = RHI::NullResource;
s_Data.m_TimerQueries[1] = RHI::NullResource;
}
s_Data.m_TimerQueryActive = false;
s_Data.m_CurrentTimerQuery = 0;
Expand Down
3 changes: 2 additions & 1 deletion OloEngine/src/OloEngine/Precipitation/PrecipitationSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "OloEngine/Core/Ref.h"
#include "OloEngine/Core/Timestep.h"
#include "OloEngine/Renderer/PostProcessSettings.h"
#include "OloEngine/Renderer/RHI/RHITypes.h"
#include <glm/glm.hpp>

namespace OloEngine
Expand Down Expand Up @@ -153,7 +154,7 @@
f32 m_DrainTimeRemaining = 0.0f;

// GPU timer query objects
u32 m_TimerQueries[2] = { 0, 0 };
RHI::ResourceHandle m_TimerQueries[2] = { RHI::NullResource, RHI::NullResource };

Check warning on line 157 in OloEngine/src/OloEngine/Precipitation/PrecipitationSystem.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "std::array" or "std::vector" instead of a C-style array.

See more on https://sonarcloud.io/project/issues?id=drsnuggles8_OloEngineBase&issues=AZ_B1AsmCO3a6BsbLDYW&open=AZ_B1AsmCO3a6BsbLDYW&pullRequest=737
u32 m_CurrentTimerQuery = 0;
bool m_TimerQueryActive = false;

Expand Down
26 changes: 13 additions & 13 deletions OloEngine/src/OloEngine/Renderer/CloudNoise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ namespace OloEngine
}

/// Dispatch one bake pass of CloudNoise_Generate.comp into a 3D volume.
void DispatchNoiseBake(const ComputeShader& shader, u32 textureID, int mode, u32 size)
void DispatchNoiseBake(const ComputeShader& shader, RHI::ResourceHandle texture, int mode, u32 size)
{
shader.SetInt("u_Mode", mode);
shader.SetInt("u_Size", static_cast<int>(size));
shader.SetFloat("u_InvSize", 1.0f / static_cast<f32>(size));

// Bind the volume for writing (image unit 0, mip 0, layered for 3D)
RenderCommand::BindImageTexture(0, textureID, 0, true, 0, RHI::Access::StorageWrite, RHI::Format::RGBA8UNorm);
RenderCommand::BindImageTexture(0, texture, 0, true, 0, RHI::Access::StorageWrite, RHI::Format::RGBA8UNorm);

const u32 groups = (size + kLocalSize - 1) / kLocalSize;
RenderCommand::DispatchCompute(groups, groups, groups);
Expand Down Expand Up @@ -134,8 +134,8 @@ namespace OloEngine
// --- Generation compute shader ---
s_Data.m_GenerateShader = ComputeShader::Create("assets/shaders/compute/CloudNoise_Generate.comp");

const bool texturesValid = s_Data.m_BaseNoise && s_Data.m_BaseNoise->GetRendererID() != 0 &&
s_Data.m_DetailNoise && s_Data.m_DetailNoise->GetRendererID() != 0;
const bool texturesValid = s_Data.m_BaseNoise && s_Data.m_BaseNoise->GetRHIHandle().IsValid() &&
s_Data.m_DetailNoise && s_Data.m_DetailNoise->GetRHIHandle().IsValid();
const bool shaderValid = s_Data.m_GenerateShader && s_Data.m_GenerateShader->IsValid();
if (!texturesValid || !shaderValid)
{
Expand All @@ -151,8 +151,8 @@ namespace OloEngine

// --- Bake both volumes on the GPU ---
s_Data.m_GenerateShader->Bind();
DispatchNoiseBake(*s_Data.m_GenerateShader, s_Data.m_BaseNoise->GetRendererID(), 0, kBaseNoiseSize);
DispatchNoiseBake(*s_Data.m_GenerateShader, s_Data.m_DetailNoise->GetRendererID(), 1, kDetailNoiseSize);
DispatchNoiseBake(*s_Data.m_GenerateShader, s_Data.m_BaseNoise->GetRHIHandle(), 0, kBaseNoiseSize);
DispatchNoiseBake(*s_Data.m_GenerateShader, s_Data.m_DetailNoise->GetRHIHandle(), 1, kDetailNoiseSize);
s_Data.m_GenerateShader->Unbind();

// --- Default weather map (deterministic CPU value-noise FBM) ---
Expand Down Expand Up @@ -205,7 +205,7 @@ namespace OloEngine
weatherSpec.Format = ImageFormat::RGBA8;
weatherSpec.GenerateMips = false;
s_Data.m_WeatherMap = Texture2D::Create(weatherSpec);
if (!s_Data.m_WeatherMap || s_Data.m_WeatherMap->GetRendererID() == 0)
if (!s_Data.m_WeatherMap || !s_Data.m_WeatherMap->GetRHIHandle().IsValid())
{
OLO_CORE_ERROR("CloudNoise::EnsureGenerated failed — default weather map texture could not be created");
s_Data.m_GenerateShader = nullptr;
Expand Down Expand Up @@ -247,18 +247,18 @@ namespace OloEngine
return s_Data.m_Generated;
}

u32 CloudNoise::GetBaseNoiseTextureID()
RHI::ResourceHandle CloudNoise::GetBaseNoiseTexture()
{
return (s_Data.m_Generated && s_Data.m_BaseNoise) ? s_Data.m_BaseNoise->GetRendererID() : 0;
return (s_Data.m_Generated && s_Data.m_BaseNoise) ? s_Data.m_BaseNoise->GetRHIHandle() : RHI::NullResource;
}

u32 CloudNoise::GetDetailNoiseTextureID()
RHI::ResourceHandle CloudNoise::GetDetailNoiseTexture()
{
return (s_Data.m_Generated && s_Data.m_DetailNoise) ? s_Data.m_DetailNoise->GetRendererID() : 0;
return (s_Data.m_Generated && s_Data.m_DetailNoise) ? s_Data.m_DetailNoise->GetRHIHandle() : RHI::NullResource;
}

u32 CloudNoise::GetDefaultWeatherMapTextureID()
RHI::ResourceHandle CloudNoise::GetDefaultWeatherMapTexture()
{
return (s_Data.m_Generated && s_Data.m_WeatherMap) ? s_Data.m_WeatherMap->GetRendererID() : 0;
return (s_Data.m_Generated && s_Data.m_WeatherMap) ? s_Data.m_WeatherMap->GetRHIHandle() : RHI::NullResource;
}
} // namespace OloEngine
17 changes: 9 additions & 8 deletions OloEngine/src/OloEngine/Renderer/CloudNoise.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "OloEngine/Core/Base.h"
#include "OloEngine/Core/Ref.h"
#include "OloEngine/Renderer/RHI/RHITypes.h"

namespace OloEngine
{
Expand Down Expand Up @@ -30,8 +31,8 @@ namespace OloEngine
* Usage:
* if (CloudNoise::EnsureGenerated())
* {
* // bind GetBaseNoiseTextureID() / GetDetailNoiseTextureID() /
* // GetDefaultWeatherMapTextureID() for the cloud raymarch
* // bind GetBaseNoiseTexture() / GetDetailNoiseTexture() /
* // GetDefaultWeatherMapTexture() for the cloud raymarch
* }
* ...
* CloudNoise::Shutdown(); // safe to call twice
Expand All @@ -51,14 +52,14 @@ namespace OloEngine
/// @return true after EnsureGenerated() succeeded.
[[nodiscard]] static bool IsReady();

/// @return GL renderer id of the 128³ RGBA8 repeat base-noise volume (0 when not ready).
[[nodiscard]] static u32 GetBaseNoiseTextureID();
/// @return identity of the 128³ RGBA8 repeat base-noise volume (null when not ready).
[[nodiscard]] static RHI::ResourceHandle GetBaseNoiseTexture();

/// @return GL renderer id of the 32³ RGBA8 repeat detail-noise volume (0 when not ready).
[[nodiscard]] static u32 GetDetailNoiseTextureID();
/// @return identity of the 32³ RGBA8 repeat detail-noise volume (null when not ready).
[[nodiscard]] static RHI::ResourceHandle GetDetailNoiseTexture();

/// @return GL renderer id of the 512² RGBA8 procedural default weather map (0 when not ready).
[[nodiscard]] static u32 GetDefaultWeatherMapTextureID();
/// @return identity of the 512² RGBA8 procedural default weather map (null when not ready).
[[nodiscard]] static RHI::ResourceHandle GetDefaultWeatherMapTexture();

private:
struct CloudNoiseData
Expand Down
19 changes: 10 additions & 9 deletions OloEngine/src/OloEngine/Renderer/Commands/CommandDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1487,10 +1487,11 @@ namespace OloEngine
bool startedConditionalRender = false;
if (cmd->occlusionQueryIndex != UINT32_MAX)
{
u32 queryID = OcclusionQueryPool::GetInstance().GetQueryID(cmd->occlusionQueryIndex);
if (queryID != 0)
const RHI::ResourceHandle query =
OcclusionQueryPool::GetInstance().GetQueryHandle(cmd->occlusionQueryIndex);
if (query.IsValid())
{
api.BeginConditionalRender(queryID);
api.BeginConditionalRender(query);
startedConditionalRender = true;
}
}
Expand Down Expand Up @@ -1588,7 +1589,7 @@ namespace OloEngine
// surviving count into `cullIndirectBufferID`. Skip the FrameDataBuffer
// -> InstanceData scratch loop and the upload; bind the pre-populated
// output buffer at SSBO_INSTANCE_DATA and draw indirect.
if (const bool useGPUCull = cmd->cullIndirectBufferID != 0 && cmd->cullOutputInstanceBufferID != 0; useGPUCull)
if (const bool useGPUCull = cmd->cullIndirectBufferID.IsValid() && cmd->cullOutputInstanceBufferID.IsValid(); useGPUCull)
{
// Rebind slot 15 to the per-submission output buffer. The engine-
// wide `s_Data.ModelInstanceBuffer` is unchanged so it can be
Expand Down Expand Up @@ -1979,7 +1980,7 @@ namespace OloEngine
if (auto terrainUBO = Renderer3D::GetTerrainUBO(); terrainUBO)
{
terrainUBO->SetData(&cmd->terrainUBOData, ShaderBindingLayout::TerrainUBO::GetSize());
api.BindUniformBuffer(ShaderBindingLayout::UBO_TERRAIN, terrainUBO->GetRendererID());
api.BindUniformBuffer(ShaderBindingLayout::UBO_TERRAIN, terrainUBO->GetRHIHandle());
}

// Bind terrain textures
Expand Down Expand Up @@ -2147,7 +2148,7 @@ namespace OloEngine
decalData.DecalColor = cmd->decalColor;
decalData.DecalParams = cmd->decalParams;
decalUBO->SetData(&decalData, ShaderBindingLayout::DecalUBO::GetSize());
api.BindUniformBuffer(ShaderBindingLayout::UBO_DECAL, decalUBO->GetRendererID());
api.BindUniformBuffer(ShaderBindingLayout::UBO_DECAL, decalUBO->GetRHIHandle());
}

// Bind albedo texture (with redundancy check)
Expand Down Expand Up @@ -2238,7 +2239,7 @@ namespace OloEngine
foliageData.ImpostorParams0 = glm::vec4(cmd->impostorFramesPerAxis, cmd->impostorHemi, cmd->impostorStartDistance, cmd->impostorBand);
foliageData.ImpostorParams1 = glm::vec4(cmd->impostorEnabled, cmd->impostorRadius, cmd->impostorParallaxScale, 0.0f);
foliageUBO->SetData(&foliageData, ShaderBindingLayout::FoliageUBO::GetSize());
api.BindUniformBuffer(ShaderBindingLayout::UBO_FOLIAGE, foliageUBO->GetRendererID());
api.BindUniformBuffer(ShaderBindingLayout::UBO_FOLIAGE, foliageUBO->GetRHIHandle());
}

// Bind albedo texture (with redundancy check). On the impostor path this
Expand Down Expand Up @@ -2327,7 +2328,7 @@ namespace OloEngine
waterData.TessParams = cmd->tessParams;
waterData.FFTParams = cmd->fftParams;
waterUBO->SetData(&waterData, ShaderBindingLayout::WaterUBO::GetSize());
api.BindUniformBuffer(ShaderBindingLayout::UBO_WATER, waterUBO->GetRendererID());
api.BindUniformBuffer(ShaderBindingLayout::UBO_WATER, waterUBO->GetRHIHandle());
}

// Bind normal map and noise textures (tracked for redundancy elimination and stats)
Expand All @@ -2353,7 +2354,7 @@ namespace OloEngine
}
else if (s_Data.BoundTextures[ShaderBindingLayout::TEX_ENVIRONMENT].IsValid())
{
api.BindTexture(ShaderBindingLayout::TEX_ENVIRONMENT, 0);
api.BindTexture(ShaderBindingLayout::TEX_ENVIRONMENT, RHI::NullResource);
s_Data.BoundTextures[ShaderBindingLayout::TEX_ENVIRONMENT] = {};
}

Expand Down
Loading
Loading