fix IDE warnings
mostly const decorators.
This commit is contained in:
committed by
Mathias Agopian
parent
575e54e5d6
commit
91cc36f1ec
@@ -143,7 +143,7 @@ AtlasAllocator::NodeId AtlasAllocator::allocateInLayer(size_t maxHeight) noexcep
|
||||
while (ppp.l > 0) {
|
||||
const size_t pi = QuadTreeUtils::parent(ppp.l, ppp.code);
|
||||
ppp = NodeId{ int8_t(ppp.l - 1), uint8_t(ppp.code >> 2) };
|
||||
Node& node = mQuadTree[pi];
|
||||
Node const& node = mQuadTree[pi];
|
||||
assert_invariant(!node.isAllocated());
|
||||
assert_invariant(node.hasChildren());
|
||||
}
|
||||
@@ -154,7 +154,7 @@ AtlasAllocator::NodeId AtlasAllocator::allocateInLayer(size_t maxHeight) noexcep
|
||||
NodeId found{ -1, 0 };
|
||||
QuadTree::traverse(candidate.l, candidate.code,
|
||||
[this, n, &found](NodeId const& curr) -> QuadTree::TraversalResult {
|
||||
size_t i = index(curr.l, curr.code);
|
||||
size_t const i = index(curr.l, curr.code);
|
||||
Node& node = mQuadTree[i];
|
||||
if (curr.l == n) {
|
||||
found = curr;
|
||||
|
||||
@@ -35,14 +35,14 @@ float3 Color::linearToSRGB(float3 color) noexcept {
|
||||
|
||||
LinearColor Color::cct(float K) {
|
||||
// temperature to CIE 1960
|
||||
float K2 = K * K;
|
||||
float u = (0.860117757f + 1.54118254e-4f * K + 1.28641212e-7f * K2) /
|
||||
float const K2 = K * K;
|
||||
float const u = (0.860117757f + 1.54118254e-4f * K + 1.28641212e-7f * K2) /
|
||||
(1.0f + 8.42420235e-4f * K + 7.08145163e-7f * K2);
|
||||
float v = (0.317398726f + 4.22806245e-5f * K + 4.20481691e-8f * K2) /
|
||||
float const v = (0.317398726f + 4.22806245e-5f * K + 4.20481691e-8f * K2) /
|
||||
(1.0f - 2.89741816e-5f * K + 1.61456053e-7f * K2);
|
||||
|
||||
float d = 1.0f / (2.0f * u - 8.0f * v + 4.0f);
|
||||
float3 linear = XYZ_to_sRGB * xyY_to_XYZ({3.0f * u * d, 2.0f * v * d, 1.0f});
|
||||
float const d = 1.0f / (2.0f * u - 8.0f * v + 4.0f);
|
||||
float3 const linear = XYZ_to_sRGB * xyY_to_XYZ({3.0f * u * d, 2.0f * v * d, 1.0f});
|
||||
// normalize and saturate
|
||||
return saturate(linear / max(1e-5f, max(linear)));
|
||||
}
|
||||
@@ -50,13 +50,13 @@ LinearColor Color::cct(float K) {
|
||||
LinearColor Color::illuminantD(float K) {
|
||||
// temperature to xyY
|
||||
const float iK = 1.0f / K;
|
||||
float iK2 = iK * iK;
|
||||
float x = K <= 7000.0f ?
|
||||
float const iK2 = iK * iK;
|
||||
float const x = K <= 7000.0f ?
|
||||
0.244063f + 0.09911e3f * iK + 2.9678e6f * iK2 - 4.6070e9f * iK2 * iK :
|
||||
0.237040f + 0.24748e3f * iK + 1.9018e6f * iK2 - 2.0064e9f * iK2 * iK;
|
||||
float y = -3.0f * x * x + 2.87f * x - 0.275f;
|
||||
float const y = -3.0f * x * x + 2.87f * x - 0.275f;
|
||||
|
||||
float3 linear = XYZ_to_sRGB * xyY_to_XYZ({x, y, 1.0f});
|
||||
float3 const linear = XYZ_to_sRGB * xyY_to_XYZ({x, y, 1.0f});
|
||||
// normalize and saturate
|
||||
return saturate(linear / max(1e-5f, max(linear)));
|
||||
}
|
||||
|
||||
@@ -98,30 +98,30 @@ static float compute_max_saturation(float a, float b) noexcept {
|
||||
// is close to infinite
|
||||
// this should be sufficient for most applications, otherwise do two/three steps
|
||||
|
||||
float k_l = +0.3963377774f * a + 0.2158037573f * b;
|
||||
float k_m = -0.1055613458f * a - 0.0638541728f * b;
|
||||
float k_s = -0.0894841775f * a - 1.2914855480f * b;
|
||||
float const k_l = +0.3963377774f * a + 0.2158037573f * b;
|
||||
float const k_m = -0.1055613458f * a - 0.0638541728f * b;
|
||||
float const k_s = -0.0894841775f * a - 1.2914855480f * b;
|
||||
|
||||
{
|
||||
float l_ = 1.f + S * k_l;
|
||||
float m_ = 1.f + S * k_m;
|
||||
float s_ = 1.f + S * k_s;
|
||||
float const l_ = 1.f + S * k_l;
|
||||
float const m_ = 1.f + S * k_m;
|
||||
float const s_ = 1.f + S * k_s;
|
||||
|
||||
float l = l_ * l_ * l_;
|
||||
float m = m_ * m_ * m_;
|
||||
float s = s_ * s_ * s_;
|
||||
float const l = l_ * l_ * l_;
|
||||
float const m = m_ * m_ * m_;
|
||||
float const s = s_ * s_ * s_;
|
||||
|
||||
float l_dS = 3.f * k_l * l_ * l_;
|
||||
float m_dS = 3.f * k_m * m_ * m_;
|
||||
float s_dS = 3.f * k_s * s_ * s_;
|
||||
float const l_dS = 3.f * k_l * l_ * l_;
|
||||
float const m_dS = 3.f * k_m * m_ * m_;
|
||||
float const s_dS = 3.f * k_s * s_ * s_;
|
||||
|
||||
float l_dS2 = 6.f * k_l * k_l * l_;
|
||||
float m_dS2 = 6.f * k_m * k_m * m_;
|
||||
float s_dS2 = 6.f * k_s * k_s * s_;
|
||||
float const l_dS2 = 6.f * k_l * k_l * l_;
|
||||
float const m_dS2 = 6.f * k_m * k_m * m_;
|
||||
float const s_dS2 = 6.f * k_s * k_s * s_;
|
||||
|
||||
float f = wl * l + wm * m + ws * s;
|
||||
float f1 = wl * l_dS + wm * m_dS + ws * s_dS;
|
||||
float f2 = wl * l_dS2 + wm * m_dS2 + ws * s_dS2;
|
||||
float const f = wl * l + wm * m + ws * s;
|
||||
float const f1 = wl * l_dS + wm * m_dS + ws * s_dS;
|
||||
float const f2 = wl * l_dS2 + wm * m_dS2 + ws * s_dS2;
|
||||
|
||||
S = S - f * f1 / (f1 * f1 - 0.5f * f * f2);
|
||||
}
|
||||
@@ -133,14 +133,14 @@ static float compute_max_saturation(float a, float b) noexcept {
|
||||
// a and b must be normalized so a^2 + b^2 == 1
|
||||
static float2 find_cusp(float a, float b) noexcept {
|
||||
// First, find the maximum saturation (saturation S = C/L)
|
||||
float S_cusp = compute_max_saturation(a, b);
|
||||
float const S_cusp = compute_max_saturation(a, b);
|
||||
|
||||
// Convert to linear sRGB to find the first point where at least one of r,g or b >= 1:
|
||||
float3 rgb_at_max = OkLab_to_sRGB({1.0f, S_cusp * a, S_cusp * b});
|
||||
float L_cusp = std::cbrt(1.0f / max(rgb_at_max));
|
||||
float C_cusp = L_cusp * S_cusp;
|
||||
float3 const rgb_at_max = OkLab_to_sRGB({1.0f, S_cusp * a, S_cusp * b});
|
||||
float const L_cusp = std::cbrt(1.0f / max(rgb_at_max));
|
||||
float const C_cusp = L_cusp * S_cusp;
|
||||
|
||||
return {L_cusp, C_cusp};
|
||||
return { L_cusp, C_cusp };
|
||||
}
|
||||
|
||||
// Finds intersection of the line defined by
|
||||
@@ -149,7 +149,7 @@ static float2 find_cusp(float a, float b) noexcept {
|
||||
// a and b must be normalized so a^2 + b^2 == 1
|
||||
static float find_gamut_intersection(float a, float b, float L1, float C1, float L0) noexcept {
|
||||
// Find the cusp of the gamut triangle
|
||||
float2 cusp = find_cusp(a, b);
|
||||
float2 const cusp = find_cusp(a, b);
|
||||
|
||||
// Find the intersection for upper and lower half separately
|
||||
float t;
|
||||
@@ -164,59 +164,59 @@ static float find_gamut_intersection(float a, float b, float L1, float C1, float
|
||||
|
||||
// Then one step Halley's method
|
||||
{
|
||||
float dL = L1 - L0;
|
||||
float dC = C1;
|
||||
float const dL = L1 - L0;
|
||||
float const dC = C1;
|
||||
|
||||
float k_l = +0.3963377774f * a + 0.2158037573f * b;
|
||||
float k_m = -0.1055613458f * a - 0.0638541728f * b;
|
||||
float k_s = -0.0894841775f * a - 1.2914855480f * b;
|
||||
float const k_l = +0.3963377774f * a + 0.2158037573f * b;
|
||||
float const k_m = -0.1055613458f * a - 0.0638541728f * b;
|
||||
float const k_s = -0.0894841775f * a - 1.2914855480f * b;
|
||||
|
||||
float l_dt = dL + dC * k_l;
|
||||
float m_dt = dL + dC * k_m;
|
||||
float s_dt = dL + dC * k_s;
|
||||
float const l_dt = dL + dC * k_l;
|
||||
float const m_dt = dL + dC * k_m;
|
||||
float const s_dt = dL + dC * k_s;
|
||||
|
||||
|
||||
// If higher accuracy is required, 2 or 3 iterations of the
|
||||
// following block can be used:
|
||||
{
|
||||
float L = L0 * (1.f - t) + t * L1;
|
||||
float C = t * C1;
|
||||
float const L = L0 * (1.f - t) + t * L1;
|
||||
float const C = t * C1;
|
||||
|
||||
float l_ = L + C * k_l;
|
||||
float m_ = L + C * k_m;
|
||||
float s_ = L + C * k_s;
|
||||
float const l_ = L + C * k_l;
|
||||
float const m_ = L + C * k_m;
|
||||
float const s_ = L + C * k_s;
|
||||
|
||||
float l = l_ * l_ * l_;
|
||||
float m = m_ * m_ * m_;
|
||||
float s = s_ * s_ * s_;
|
||||
float const l = l_ * l_ * l_;
|
||||
float const m = m_ * m_ * m_;
|
||||
float const s = s_ * s_ * s_;
|
||||
|
||||
float ldt = 3 * l_dt * l_ * l_;
|
||||
float mdt = 3 * m_dt * m_ * m_;
|
||||
float sdt = 3 * s_dt * s_ * s_;
|
||||
float const ldt = 3 * l_dt * l_ * l_;
|
||||
float const mdt = 3 * m_dt * m_ * m_;
|
||||
float const sdt = 3 * s_dt * s_ * s_;
|
||||
|
||||
float ldt2 = 6 * l_dt * l_dt * l_;
|
||||
float mdt2 = 6 * m_dt * m_dt * m_;
|
||||
float sdt2 = 6 * s_dt * s_dt * s_;
|
||||
float const ldt2 = 6 * l_dt * l_dt * l_;
|
||||
float const mdt2 = 6 * m_dt * m_dt * m_;
|
||||
float const sdt2 = 6 * s_dt * s_dt * s_;
|
||||
|
||||
float r = 4.0767416621f * l - 3.3077115913f * m + 0.2309699292f * s - 1;
|
||||
float r1 = 4.0767416621f * ldt - 3.3077115913f * mdt + 0.2309699292f * sdt;
|
||||
float r2 = 4.0767416621f * ldt2 - 3.3077115913f * mdt2 + 0.2309699292f * sdt2;
|
||||
float const r = 4.0767416621f * l - 3.3077115913f * m + 0.2309699292f * s - 1;
|
||||
float const r1 = 4.0767416621f * ldt - 3.3077115913f * mdt + 0.2309699292f * sdt;
|
||||
float const r2 = 4.0767416621f * ldt2 - 3.3077115913f * mdt2 + 0.2309699292f * sdt2;
|
||||
|
||||
float u_r = r1 / (r1 * r1 - 0.5f * r * r2);
|
||||
float const u_r = r1 / (r1 * r1 - 0.5f * r * r2);
|
||||
float t_r = -r * u_r;
|
||||
|
||||
float g = -1.2681437731f * l + 2.6097574011f * m - 0.3413193965f * s - 1;
|
||||
float g1 = -1.2681437731f * ldt + 2.6097574011f * mdt - 0.3413193965f * sdt;
|
||||
float g2 = -1.2681437731f * ldt2 + 2.6097574011f * mdt2 - 0.3413193965f * sdt2;
|
||||
float const g = -1.2681437731f * l + 2.6097574011f * m - 0.3413193965f * s - 1;
|
||||
float const g1 = -1.2681437731f * ldt + 2.6097574011f * mdt - 0.3413193965f * sdt;
|
||||
float const g2 = -1.2681437731f * ldt2 + 2.6097574011f * mdt2 - 0.3413193965f * sdt2;
|
||||
|
||||
float u_g = g1 / (g1 * g1 - 0.5f * g * g2);
|
||||
float const u_g = g1 / (g1 * g1 - 0.5f * g * g2);
|
||||
float t_g = -g * u_g;
|
||||
|
||||
float b0 = -0.0041960863f * l - 0.7034186147f * m + 1.7076147010f * s - 1;
|
||||
float b1 = -0.0041960863f * ldt - 0.7034186147f * mdt + 1.7076147010f * sdt;
|
||||
float b2 = -0.0041960863f * ldt2 - 0.7034186147f * mdt2 + 1.7076147010f * sdt2;
|
||||
float const b0 = -0.0041960863f * l - 0.7034186147f * m + 1.7076147010f * s - 1;
|
||||
float const b1 = -0.0041960863f * ldt - 0.7034186147f * mdt + 1.7076147010f * sdt;
|
||||
float const b2 = -0.0041960863f * ldt2 - 0.7034186147f * mdt2 + 1.7076147010f * sdt2;
|
||||
|
||||
float u_b = b1 / (b1 * b1 - 0.5f * b0 * b2);
|
||||
float const u_b = b1 / (b1 * b1 - 0.5f * b0 * b2);
|
||||
float t_b = -b0 * u_b;
|
||||
|
||||
t_r = u_r >= 0.f ? t_r : std::numeric_limits<float>::max();
|
||||
@@ -247,21 +247,21 @@ inline float3 gamut_clip_adaptive_L0_0_5(float3 rgb,
|
||||
return rgb;
|
||||
}
|
||||
|
||||
float3 lab = sRGB_to_OkLab(rgb);
|
||||
float3 const lab = sRGB_to_OkLab(rgb);
|
||||
|
||||
float L = lab.x;
|
||||
float eps = 0.00001f;
|
||||
float C = max(eps, std::sqrt(lab.y * lab.y + lab.z * lab.z));
|
||||
float a_ = lab.y / C;
|
||||
float b_ = lab.z / C;
|
||||
float const L = lab.x;
|
||||
float const eps = 0.00001f;
|
||||
float const C = max(eps, std::sqrt(lab.y * lab.y + lab.z * lab.z));
|
||||
float const a_ = lab.y / C;
|
||||
float const b_ = lab.z / C;
|
||||
|
||||
float Ld = L - 0.5f;
|
||||
float e1 = 0.5f + std::abs(Ld) + alpha * C;
|
||||
float L0 = 0.5f * (1.0f + sgn(Ld) * (e1 - std::sqrt(e1 * e1 - 2.0f * std::abs(Ld))));
|
||||
float const Ld = L - 0.5f;
|
||||
float const e1 = 0.5f + std::abs(Ld) + alpha * C;
|
||||
float const L0 = 0.5f * (1.0f + sgn(Ld) * (e1 - std::sqrt(e1 * e1 - 2.0f * std::abs(Ld))));
|
||||
|
||||
float t = find_gamut_intersection(a_, b_, L, C, L0);
|
||||
float L_clipped = L0 * (1.f - t) + t * L;
|
||||
float C_clipped = t * C;
|
||||
float const t = find_gamut_intersection(a_, b_, L, C, L0);
|
||||
float const L_clipped = L0 * (1.f - t) + t * L;
|
||||
float const C_clipped = t * C;
|
||||
|
||||
return OkLab_to_sRGB({L_clipped, C_clipped * a_, C_clipped * b_});
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ PostProcessManager::PostProcessMaterial::PostProcessMaterial() noexcept {
|
||||
mData = nullptr;
|
||||
}
|
||||
|
||||
PostProcessManager::PostProcessMaterial::PostProcessMaterial(FEngine& engine,
|
||||
PostProcessManager::PostProcessMaterial::PostProcessMaterial(FEngine&,
|
||||
uint8_t const* data, int size) noexcept
|
||||
: PostProcessMaterial() {
|
||||
mData = data; // aliased to mMaterial
|
||||
@@ -270,7 +270,7 @@ void PostProcessManager::init() noexcept {
|
||||
PixelBufferDescriptor dataStarburst(driver.allocate(256), 256, PixelDataFormat::R, PixelDataType::UBYTE);
|
||||
std::generate_n((uint8_t*)dataStarburst.buffer, 256,
|
||||
[&dist = mUniformDistribution, &gen = mEngine.getRandomEngine()]() {
|
||||
float r = 0.5f + 0.5f * dist(gen);
|
||||
float const r = 0.5f + 0.5f * dist(gen);
|
||||
return uint8_t(r * 255.0f);
|
||||
});
|
||||
|
||||
@@ -316,10 +316,10 @@ void PostProcessManager::render(FrameGraphResources::RenderPassInfo const& out,
|
||||
&& !pipeline.rasterState.depthWrite)
|
||||
|| !(out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH));
|
||||
|
||||
FEngine& engine = mEngine;
|
||||
Handle<HwRenderPrimitive> fullScreenRenderPrimitive = engine.getFullScreenRenderPrimitive();
|
||||
FEngine const& engine = mEngine;
|
||||
Handle<HwRenderPrimitive> const fullScreenQuad = engine.getFullScreenRenderPrimitive();
|
||||
driver.beginRenderPass(out.target, out.params);
|
||||
driver.draw(pipeline, fullScreenRenderPrimitive, 1);
|
||||
driver.draw(pipeline, fullScreenQuad, 1);
|
||||
driver.endRenderPass();
|
||||
}
|
||||
|
||||
@@ -357,8 +357,8 @@ PostProcessManager::StructurePassOutput PostProcessManager::structure(FrameGraph
|
||||
};
|
||||
|
||||
// sanitize a bit the user provided scaling factor
|
||||
width = std::max(32u, (uint32_t)std::ceil(width * scale));
|
||||
height = std::max(32u, (uint32_t)std::ceil(height * scale));
|
||||
width = std::max(32u, (uint32_t)std::ceil(float(width) * scale));
|
||||
height = std::max(32u, (uint32_t)std::ceil(float(height) * scale));
|
||||
|
||||
// We limit the lowest lod size to 32 pixels (which is where the -5 comes from)
|
||||
const size_t levelCount = std::min(8, FTexture::maxLevelCount(width, height) - 5);
|
||||
@@ -393,7 +393,7 @@ PostProcessManager::StructurePassOutput PostProcessManager::structure(FrameGraph
|
||||
});
|
||||
},
|
||||
[=, renderPass = pass](FrameGraphResources const& resources,
|
||||
auto const& data, DriverApi& driver) mutable {
|
||||
auto const&, DriverApi&) mutable {
|
||||
Variant structureVariant(Variant::DEPTH_VARIANT);
|
||||
structureVariant.setPicking(config.picking);
|
||||
|
||||
@@ -523,12 +523,12 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::ssr(FrameGraph& fg,
|
||||
resources.getTexture(data.structure) : getOneTexture());
|
||||
|
||||
// set screen-space reflections and screen-space refractions
|
||||
mat4f uvFromViewMatrix = uvFromClipMatrix * projection;
|
||||
mat4f reprojection = mat4f{ uvFromClipMatrix * historyProjection
|
||||
mat4f const uvFromViewMatrix = uvFromClipMatrix * projection;
|
||||
mat4f const reprojection = mat4f{ uvFromClipMatrix * historyProjection
|
||||
* inverse(userViewMatrix) };
|
||||
|
||||
// the history sampler is a regular texture2D
|
||||
TextureHandle history = data.history ?
|
||||
TextureHandle const history = data.history ?
|
||||
resources.getTexture(data.history) : getZeroTexture();
|
||||
uniforms.prepareHistorySSR(history, reprojection, uvFromViewMatrix, options);
|
||||
|
||||
@@ -554,7 +554,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::ssr(FrameGraph& fg,
|
||||
}
|
||||
|
||||
FrameGraphId<FrameGraphTexture> PostProcessManager::screenSpaceAmbientOcclusion(FrameGraph& fg,
|
||||
filament::Viewport const& svp, const CameraInfo& cameraInfo,
|
||||
filament::Viewport const&, const CameraInfo& cameraInfo,
|
||||
FrameGraphId<FrameGraphTexture> depth,
|
||||
AmbientOcclusionOptions const& options) noexcept {
|
||||
assert_invariant(depth);
|
||||
@@ -799,7 +799,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::screenSpaceAmbientOcclusion(
|
||||
float2{ options.ssct.depthBias, options.ssct.depthSlopeBias });
|
||||
mi->setParameter("ssctSampleCount", uint32_t(options.ssct.sampleCount));
|
||||
mi->setParameter("ssctRayCount",
|
||||
float2{ options.ssct.rayCount, 1.0f / options.ssct.rayCount });
|
||||
float2{ options.ssct.rayCount, 1.0f / float(options.ssct.rayCount) });
|
||||
|
||||
mi->commit(driver);
|
||||
mi->use(driver);
|
||||
@@ -895,15 +895,15 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::bilateralBlurPass(FrameGraph
|
||||
[kernelArraySize](float* outKernel, size_t gaussianWidth, float stdDev) -> uint32_t {
|
||||
const size_t gaussianSampleCount = std::min(kernelArraySize, (gaussianWidth + 1u) / 2u);
|
||||
for (size_t i = 0; i < gaussianSampleCount; i++) {
|
||||
float x = i;
|
||||
float g = std::exp(-(x * x) / (2.0f * stdDev * stdDev));
|
||||
float const x = float(i);
|
||||
float const g = std::exp(-(x * x) / (2.0f * stdDev * stdDev));
|
||||
outKernel[i] = g;
|
||||
}
|
||||
return uint32_t(gaussianSampleCount);
|
||||
};
|
||||
|
||||
float kGaussianSamples[kernelArraySize];
|
||||
uint32_t kGaussianCount = gaussianKernel(kGaussianSamples,
|
||||
uint32_t const kGaussianCount = gaussianKernel(kGaussianSamples,
|
||||
config.kernelSize, config.standardDeviation);
|
||||
|
||||
auto& material = config.bentNormals ?
|
||||
@@ -987,10 +987,10 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::gaussianBlurPass(FrameGraph&
|
||||
float totalWeight = kernel[0].x;
|
||||
|
||||
for (size_t i = 1; i < m; i++) {
|
||||
float x0 = float(i * 2 - 1);
|
||||
float x1 = float(i * 2);
|
||||
float k0 = std::exp(-alpha * x0 * x0);
|
||||
float k1 = std::exp(-alpha * x1 * x1);
|
||||
float const x0 = float(i * 2 - 1);
|
||||
float const x1 = float(i * 2);
|
||||
float const k0 = std::exp(-alpha * x0 * x0);
|
||||
float const k1 = std::exp(-alpha * x1 * x1);
|
||||
|
||||
// k * textureLod(..., o) with bilinear sampling is equivalent to:
|
||||
// k * (s[0] * (1 - o) + s[1] * o)
|
||||
@@ -998,8 +998,8 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::gaussianBlurPass(FrameGraph&
|
||||
// k0 = k * (1 - o)
|
||||
// k1 = k * o
|
||||
|
||||
float k = k0 + k1;
|
||||
float o = k1 / k;
|
||||
float const k = k0 + k1;
|
||||
float const o = k1 / k;
|
||||
kernel[i].x = k;
|
||||
kernel[i].y = o;
|
||||
totalWeight += (k0 + k1) * 2.0f;
|
||||
@@ -1079,7 +1079,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::gaussianBlurPass(FrameGraph&
|
||||
const size_t kernelStorageSize = mi->getMaterial()->reflect("kernel")->size;
|
||||
|
||||
float2 kernel[64];
|
||||
size_t m = computeGaussianCoefficients(kernel,
|
||||
size_t const m = computeGaussianCoefficients(kernel,
|
||||
std::min(sizeof(kernel) / sizeof(*kernel), kernelStorageSize));
|
||||
|
||||
// horizontal pass
|
||||
@@ -1509,7 +1509,9 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::dof(FrameGraph& fg,
|
||||
mi->setParameter("cocClamp", float2{
|
||||
-(dofOptions.maxForegroundCOC ? dofOptions.maxForegroundCOC : DOF_DEFAULT_MAX_COC),
|
||||
dofOptions.maxBackgroundCOC ? dofOptions.maxBackgroundCOC : DOF_DEFAULT_MAX_COC});
|
||||
mi->setParameter("texelSize", float2{ 1.0f / colorDesc.width, 1.0f / colorDesc.height });
|
||||
mi->setParameter("texelSize", float2{
|
||||
1.0f / float(colorDesc.width),
|
||||
1.0f / float(colorDesc.height) });
|
||||
commitAndRender(out, material, driver);
|
||||
});
|
||||
|
||||
@@ -1732,7 +1734,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::dof(FrameGraph& fg,
|
||||
bokehAspectRatio / (inputDesc.width * dofResolution),
|
||||
1.0 / (inputDesc.height * dofResolution)
|
||||
});
|
||||
mi->setParameter("cocToPixelScale", (1.0f / dofResolution));
|
||||
mi->setParameter("cocToPixelScale", (1.0f / float(dofResolution)));
|
||||
mi->setParameter("ringCounts", float4{
|
||||
dofOptions.foregroundRingCount ? dofOptions.foregroundRingCount : DOF_DEFAULT_RING_COUNT,
|
||||
dofOptions.backgroundRingCount ? dofOptions.backgroundRingCount : DOF_DEFAULT_RING_COUNT,
|
||||
@@ -2002,10 +2004,10 @@ PostProcessManager::BloomPassOutput PostProcessManager::bloomPass(FrameGraph& fg
|
||||
for (size_t i = 0; i < inoutBloomOptions.levels; i++) {
|
||||
auto out = builder.createSubresource(data.out, "Bloom Out Texture mip",
|
||||
{ .level = uint8_t(i) });
|
||||
auto stage = builder.createSubresource(data.stage,
|
||||
auto staging = builder.createSubresource(data.stage,
|
||||
"Bloom Stage Texture mip", { .level = uint8_t(i) });
|
||||
builder.declareRenderPass(out, &data.outRT[i]);
|
||||
builder.declareRenderPass(stage, &data.stageRT[i]);
|
||||
builder.declareRenderPass(staging, &data.stageRT[i]);
|
||||
}
|
||||
},
|
||||
[=](FrameGraphResources const& resources, auto const& data, DriverApi& driver) {
|
||||
@@ -2096,7 +2098,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::flarePass(FrameGraph& fg,
|
||||
auto const& data, DriverApi& driver) {
|
||||
auto in = resources.getTexture(data.in);
|
||||
auto out = resources.getRenderPassInfo(0);
|
||||
const float aspectRatio = float(width) / height;
|
||||
const float aspectRatio = float(width) / float(height);
|
||||
|
||||
auto const& material = getPostProcessMaterial("flare");
|
||||
FMaterialInstance* mi = material.getMaterialInstance(mEngine);
|
||||
@@ -2132,21 +2134,21 @@ static float4 getVignetteParameters(VignetteOptions const& options,
|
||||
// Vignette params
|
||||
// From 0.0 to 0.5 the vignette is a rounded rect that turns into an oval
|
||||
// From 0.5 to 1.0 the vignette turns from oval to circle
|
||||
float oval = min(options.roundness, 0.5f) * 2.0f;
|
||||
float circle = (max(options.roundness, 0.5f) - 0.5f) * 2.0f;
|
||||
float roundness = (1.0f - oval) * 6.0f + oval;
|
||||
float const oval = min(options.roundness, 0.5f) * 2.0f;
|
||||
float const circle = (max(options.roundness, 0.5f) - 0.5f) * 2.0f;
|
||||
float const roundness = (1.0f - oval) * 6.0f + oval;
|
||||
|
||||
// Mid point varies during the oval/rounded section of roundness
|
||||
// We also modify it to emphasize feathering
|
||||
float midPoint = (1.0f - options.midPoint) * mix(2.2f, 3.0f, oval)
|
||||
float const midPoint = (1.0f - options.midPoint) * mix(2.2f, 3.0f, oval)
|
||||
* (1.0f - 0.1f * options.feather);
|
||||
|
||||
// Radius of the rounded corners as a param to pow()
|
||||
float radius = roundness *
|
||||
float const radius = roundness *
|
||||
mix(1.0f + 4.0f * (1.0f - options.feather), 1.0f, std::sqrt(oval));
|
||||
|
||||
// Factor to transform oval into circle
|
||||
float aspect = mix(1.0f, float(width) / float(height), circle);
|
||||
float const aspect = mix(1.0f, float(width) / float(height), circle);
|
||||
|
||||
return float4{ midPoint, radius, aspect, options.feather };
|
||||
}
|
||||
@@ -2159,7 +2161,7 @@ void PostProcessManager::colorGradingPrepareSubpass(DriverApi& driver,
|
||||
const FColorGrading* colorGrading, ColorGradingConfig const& colorGradingConfig,
|
||||
VignetteOptions const& vignetteOptions, uint32_t width, uint32_t height) noexcept {
|
||||
|
||||
float4 vignetteParameters = getVignetteParameters(vignetteOptions, width, height);
|
||||
float4 const vignetteParameters = getVignetteParameters(vignetteOptions, width, height);
|
||||
|
||||
auto const& material = getPostProcessMaterial("colorGradingAsSubpass");
|
||||
FMaterialInstance* mi = material.getMaterialInstance(mEngine);
|
||||
@@ -2193,7 +2195,7 @@ void PostProcessManager::colorGradingPrepareSubpass(DriverApi& driver,
|
||||
|
||||
void PostProcessManager::colorGradingSubpass(DriverApi& driver,
|
||||
ColorGradingConfig const& colorGradingConfig) noexcept {
|
||||
FEngine& engine = mEngine;
|
||||
FEngine const& engine = mEngine;
|
||||
Handle<HwRenderPrimitive> const& fullScreenRenderPrimitive = engine.getFullScreenRenderPrimitive();
|
||||
|
||||
auto const& material = getPostProcessMaterial("colorGradingAsSubpass");
|
||||
@@ -2216,7 +2218,7 @@ void PostProcessManager::customResolvePrepareSubpass(DriverApi& driver, CustomRe
|
||||
}
|
||||
|
||||
void PostProcessManager::customResolveSubpass(DriverApi& driver) noexcept {
|
||||
FEngine& engine = mEngine;
|
||||
FEngine const& engine = mEngine;
|
||||
Handle<HwRenderPrimitive> const& fullScreenRenderPrimitive = engine.getFullScreenRenderPrimitive();
|
||||
auto const& material = getPostProcessMaterial("customResolveAsSubpass");
|
||||
// the UBO has been set and committed in colorGradingPrepareSubpass()
|
||||
@@ -2239,7 +2241,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::customResolveUncompressPass(
|
||||
.attachments = { .color = { data.inout }}
|
||||
});
|
||||
},
|
||||
[=](FrameGraphResources const& resources, auto const& data, DriverApi& driver) {
|
||||
[=](FrameGraphResources const& resources, auto const&, DriverApi& driver) {
|
||||
customResolvePrepareSubpass(driver, CustomResolveOp::UNCOMPRESS);
|
||||
auto out = resources.getRenderPassInfo();
|
||||
out.params.subpassMask = 1;
|
||||
@@ -2267,7 +2269,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::colorGrading(FrameGraph& fg,
|
||||
bloomStrength = clamp(bloomOptions.strength, 0.0f, 1.0f);
|
||||
if (bloomOptions.dirt) {
|
||||
FTexture* fdirt = downcast(bloomOptions.dirt);
|
||||
FrameGraphTexture frameGraphTexture{ .handle = fdirt->getHwHandle() };
|
||||
FrameGraphTexture const frameGraphTexture{ .handle = fdirt->getHwHandle() };
|
||||
bloomDirt = fg.import("dirt", {
|
||||
.width = (uint32_t)fdirt->getWidth(0u),
|
||||
.height = (uint32_t)fdirt->getHeight(0u),
|
||||
@@ -2316,18 +2318,18 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::colorGrading(FrameGraph& fg,
|
||||
}
|
||||
},
|
||||
[=](FrameGraphResources const& resources, auto const& data, DriverApi& driver) {
|
||||
Handle<HwTexture> colorTexture = resources.getTexture(data.input);
|
||||
auto colorTexture = resources.getTexture(data.input);
|
||||
|
||||
Handle<HwTexture> bloomTexture =
|
||||
auto bloomTexture =
|
||||
data.bloom ? resources.getTexture(data.bloom) : getZeroTexture();
|
||||
|
||||
Handle<HwTexture> flareTexture =
|
||||
auto flareTexture =
|
||||
data.flare ? resources.getTexture(data.flare) : getZeroTexture();
|
||||
|
||||
Handle<HwTexture> dirtTexture =
|
||||
auto dirtTexture =
|
||||
data.dirt ? resources.getTexture(data.dirt) : getOneTexture();
|
||||
|
||||
Handle<HwTexture> starburstTexture =
|
||||
auto starburstTexture =
|
||||
data.starburst ? resources.getTexture(data.starburst) : getOneTexture();
|
||||
|
||||
auto const& out = resources.getRenderPassInfo();
|
||||
@@ -2376,7 +2378,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::colorGrading(FrameGraph& fg,
|
||||
|
||||
auto const& input = resources.getDescriptor(data.input);
|
||||
auto const& output = resources.getDescriptor(data.output);
|
||||
float4 vignetteParameters = getVignetteParameters(
|
||||
float4 const vignetteParameters = getVignetteParameters(
|
||||
vignetteOptions, output.width, output.height);
|
||||
|
||||
const float temporalNoise = mUniformDistribution(mEngine.getRandomEngine());
|
||||
@@ -2464,10 +2466,10 @@ void PostProcessManager::prepareTaa(FrameGraph& fg, filament::Viewport const& sv
|
||||
current.frameId = previous.frameId + 1;
|
||||
|
||||
// sample position within a pixel [-0.5, 0.5]
|
||||
const float2 jitter = halton(previous.frameId) - 0.5f;
|
||||
float2 const jitter = halton(previous.frameId) - 0.5f;
|
||||
current.jitter = jitter;
|
||||
|
||||
float2 jitterInClipSpace = jitter * (2.0f / float2{ svp.width, svp.height });
|
||||
float2 const jitterInClipSpace = jitter * (2.0f / float2{ svp.width, svp.height });
|
||||
|
||||
// update projection matrix
|
||||
inoutCameraInfo->projection[2].xy -= jitterInClipSpace;
|
||||
@@ -2597,7 +2599,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::taa(FrameGraph& fg,
|
||||
if (colorGradingConfig.asSubpass) {
|
||||
out.params.subpassMask = 1;
|
||||
}
|
||||
PipelineState pipeline(material.getPipelineState(mEngine, variant));
|
||||
PipelineState const pipeline(material.getPipelineState(mEngine, variant));
|
||||
driver.beginRenderPass(out.target, out.params);
|
||||
driver.draw(pipeline, mEngine.getFullScreenRenderPrimitive(), 1);
|
||||
if (colorGradingConfig.asSubpass) {
|
||||
@@ -2659,7 +2661,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::opaqueBlit(FrameGraph& fg,
|
||||
.viewport = vp
|
||||
});
|
||||
},
|
||||
[=](FrameGraphResources const& resources, auto const& data, DriverApi& driver) {
|
||||
[=](FrameGraphResources const& resources, auto const&, DriverApi& driver) {
|
||||
auto out = resources.getRenderPassInfo(0);
|
||||
auto in = resources.getRenderPassInfo(1);
|
||||
driver.blit(TargetBufferFlags::COLOR,
|
||||
@@ -2780,7 +2782,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::upscale(FrameGraph& fg, bool
|
||||
{ // just a scope to not leak local variables
|
||||
const std::string_view blitterNames[4] = {
|
||||
"blitLow", "fsr_easu_mobile", "fsr_easu_mobile", "fsr_easu" };
|
||||
unsigned index = std::min(3u, (unsigned)dsrOptions.quality);
|
||||
unsigned const index = std::min(3u, (unsigned)dsrOptions.quality);
|
||||
easuMaterial = &getPostProcessMaterial(blitterNames[index]);
|
||||
auto* mi = easuMaterial->getMaterialInstance(mEngine);
|
||||
if (dsrOptions.quality != QualityLevel::LOW) {
|
||||
@@ -2866,7 +2868,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::upscale(FrameGraph& fg, bool
|
||||
const uint8_t variant = uint8_t(translucent ?
|
||||
PostProcessVariant::TRANSLUCENT : PostProcessVariant::OPAQUE);
|
||||
|
||||
PipelineState pipeline(material.getPipelineState(mEngine, variant));
|
||||
PipelineState const pipeline(material.getPipelineState(mEngine, variant));
|
||||
render(out, pipeline, driver);
|
||||
});
|
||||
|
||||
@@ -2992,7 +2994,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::vsmMipmapPass(FrameGraph& fg
|
||||
auto const& inDesc = resources.getDescriptor(data.in);
|
||||
auto width = inDesc.width;
|
||||
assert_invariant(width == inDesc.height);
|
||||
int dim = width >> (level + 1);
|
||||
int const dim = width >> (level + 1);
|
||||
|
||||
driver.setMinMaxLevels(in, level, level);
|
||||
|
||||
@@ -3010,7 +3012,7 @@ FrameGraphId<FrameGraphTexture> PostProcessManager::vsmMipmapPass(FrameGraph& fg
|
||||
});
|
||||
mi->setParameter("level", uint32_t(level));
|
||||
mi->setParameter("layer", uint32_t(layer));
|
||||
mi->setParameter("uvscale", 1.0f / dim);
|
||||
mi->setParameter("uvscale", 1.0f / float(dim));
|
||||
mi->commit(driver);
|
||||
mi->use(driver);
|
||||
render(out, pipeline, driver);
|
||||
|
||||
@@ -45,7 +45,7 @@ void FCameraManager::terminate() noexcept {
|
||||
<< " leaked Camera components" << io::endl;
|
||||
#endif
|
||||
while (!manager.empty()) {
|
||||
Instance ci = manager.end() - 1;
|
||||
Instance const ci = manager.end() - 1;
|
||||
destroy(manager.getEntity(ci));
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ FCamera* FCameraManager::create(Entity entity) {
|
||||
if (UTILS_UNLIKELY(manager.hasComponent(entity))) {
|
||||
destroy(entity);
|
||||
}
|
||||
Instance i = manager.addComponent(entity);
|
||||
Instance const i = manager.addComponent(entity);
|
||||
|
||||
FCamera* camera = engine.getHeapAllocator().make<FCamera>(engine, entity);
|
||||
manager.elementAt<CAMERA>(i) = camera;
|
||||
@@ -80,7 +80,7 @@ FCamera* FCameraManager::create(Entity entity) {
|
||||
|
||||
void FCameraManager::destroy(Entity e) noexcept {
|
||||
auto& manager = mManager;
|
||||
Instance i = manager.getInstance(e);
|
||||
Instance const i = manager.getInstance(e);
|
||||
if (i) {
|
||||
FCamera* camera = manager.elementAt<CAMERA>(i);
|
||||
assert_invariant(camera);
|
||||
|
||||
@@ -163,7 +163,7 @@ FLightManager::~FLightManager() {
|
||||
assert_invariant(mManager.getComponentCount() == 0);
|
||||
}
|
||||
|
||||
void FLightManager::init(FEngine& engine) noexcept {
|
||||
void FLightManager::init(FEngine&) noexcept {
|
||||
}
|
||||
|
||||
void FLightManager::create(const FLightManager::Builder& builder, utils::Entity entity) {
|
||||
@@ -172,7 +172,7 @@ void FLightManager::create(const FLightManager::Builder& builder, utils::Entity
|
||||
if (UTILS_UNLIKELY(manager.hasComponent(entity))) {
|
||||
destroy(entity);
|
||||
}
|
||||
Instance i = manager.addComponent(entity);
|
||||
Instance const i = manager.addComponent(entity);
|
||||
assert_invariant(i);
|
||||
|
||||
if (i) {
|
||||
@@ -202,11 +202,11 @@ void FLightManager::create(const FLightManager::Builder& builder, utils::Entity
|
||||
}
|
||||
}
|
||||
|
||||
void FLightManager::prepare(backend::DriverApi& driver) const noexcept {
|
||||
void FLightManager::prepare(backend::DriverApi&) const noexcept {
|
||||
}
|
||||
|
||||
void FLightManager::destroy(utils::Entity e) noexcept {
|
||||
Instance i = getInstance(e);
|
||||
Instance const i = getInstance(e);
|
||||
if (i) {
|
||||
auto& manager = mManager;
|
||||
manager.removeComponent(e);
|
||||
@@ -221,7 +221,7 @@ void FLightManager::terminate() noexcept {
|
||||
<< " leaked Light components" << io::endl;
|
||||
#endif
|
||||
while (!manager.empty()) {
|
||||
Instance ci = manager.end() - 1;
|
||||
Instance const ci = manager.end() - 1;
|
||||
manager.removeComponent(manager.getEntity(ci));
|
||||
}
|
||||
}
|
||||
@@ -289,7 +289,7 @@ void FLightManager::setColor(Instance i, const LinearColor& color) noexcept {
|
||||
void FLightManager::setIntensity(Instance i, float intensity, IntensityUnit unit) noexcept {
|
||||
auto& manager = mManager;
|
||||
if (i) {
|
||||
Type type = getLightType(i).type;
|
||||
Type const type = getLightType(i).type;
|
||||
float luminousPower = intensity;
|
||||
float luminousIntensity;
|
||||
switch (type) {
|
||||
@@ -312,7 +312,7 @@ void FLightManager::setIntensity(Instance i, float intensity, IntensityUnit unit
|
||||
|
||||
case Type::FOCUSED_SPOT: {
|
||||
SpotParams& spotParams = manager[i].spotParams;
|
||||
float cosOuter = std::sqrt(spotParams.cosOuterSquared);
|
||||
float const cosOuter = std::sqrt(spotParams.cosOuterSquared);
|
||||
if (unit == IntensityUnit::LUMEN_LUX) {
|
||||
// li = lp / (2 * pi * (1 - cos(cone_outer / 2)))
|
||||
luminousIntensity = luminousPower / (f::TAU * (1.0f - cosOuter));
|
||||
@@ -344,7 +344,7 @@ void FLightManager::setIntensity(Instance i, float intensity, IntensityUnit unit
|
||||
void FLightManager::setFalloff(Instance i, float falloff) noexcept {
|
||||
auto& manager = mManager;
|
||||
if (i && !isDirectionalLight(i)) {
|
||||
float sqFalloff = falloff * falloff;
|
||||
float const sqFalloff = falloff * falloff;
|
||||
SpotParams& spotParams = manager[i].spotParams;
|
||||
manager[i].squaredFallOffInv = sqFalloff > 0.0f ? (1 / sqFalloff) : 0;
|
||||
spotParams.radius = falloff;
|
||||
@@ -356,16 +356,16 @@ void FLightManager::setSpotLightCone(Instance i, float inner, float outer) noexc
|
||||
if (i && isSpotLight(i)) {
|
||||
// clamp the inner/outer angles to [0.5 degrees, 90 degrees]
|
||||
float innerClamped = std::clamp(std::abs(inner), 0.5f * f::DEG_TO_RAD, f::PI_2);
|
||||
float outerClamped = std::clamp(std::abs(outer), 0.5f * f::DEG_TO_RAD, f::PI_2);
|
||||
float const outerClamped = std::clamp(std::abs(outer), 0.5f * f::DEG_TO_RAD, f::PI_2);
|
||||
|
||||
// inner must always be smaller than outer
|
||||
innerClamped = std::min(innerClamped, outerClamped);
|
||||
|
||||
float cosOuter = fast::cos(outerClamped);
|
||||
float cosInner = fast::cos(innerClamped);
|
||||
float cosOuterSquared = cosOuter * cosOuter;
|
||||
float scale = 1.0f / std::max(1.0f / 1024.0f, cosInner - cosOuter);
|
||||
float offset = -cosOuter * scale;
|
||||
float const cosOuter = fast::cos(outerClamped);
|
||||
float const cosInner = fast::cos(innerClamped);
|
||||
float const cosOuterSquared = cosOuter * cosOuter;
|
||||
float const scale = 1.0f / std::max(1.0f / 1024.0f, cosInner - cosOuter);
|
||||
float const offset = -cosOuter * scale;
|
||||
|
||||
SpotParams& spotParams = manager[i].spotParams;
|
||||
spotParams.outerClamped = outerClamped;
|
||||
@@ -374,11 +374,11 @@ void FLightManager::setSpotLightCone(Instance i, float inner, float outer) noexc
|
||||
spotParams.scaleOffset = { scale, offset };
|
||||
|
||||
// we need to recompute the luminous intensity
|
||||
Type type = getLightType(i).type;
|
||||
Type const type = getLightType(i).type;
|
||||
if (type == Type::FOCUSED_SPOT) {
|
||||
// li = lp / (2 * pi * (1 - cos(cone_outer / 2)))
|
||||
float luminousPower = spotParams.luminousPower;
|
||||
float luminousIntensity = luminousPower / (f::TAU * (1.0f - cosOuter));
|
||||
float const luminousPower = spotParams.luminousPower;
|
||||
float const luminousIntensity = luminousPower / (f::TAU * (1.0f - cosOuter));
|
||||
manager[i].intensity = luminousIntensity;
|
||||
}
|
||||
}
|
||||
@@ -412,9 +412,9 @@ void FLightManager::setShadowCaster(Instance i, bool shadowCaster) noexcept {
|
||||
|
||||
float FLightManager::getSpotLightInnerCone(Instance i) const noexcept {
|
||||
const auto& spotParams = getSpotParams(i);
|
||||
float cosOuter = std::cos(spotParams.outerClamped);
|
||||
float scale = spotParams.scaleOffset.x;
|
||||
float inner = std::acos((1.0f / scale) + cosOuter);
|
||||
float const cosOuter = std::cos(spotParams.outerClamped);
|
||||
float const scale = spotParams.scaleOffset.x;
|
||||
float const inner = std::acos((1.0f / scale) + cosOuter);
|
||||
return inner;
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ void LightManager::ShadowCascades::computeUniformSplits(float splitPositions[3],
|
||||
size_t s = 0;
|
||||
cascades = max(cascades, (uint8_t) 4u);
|
||||
for (size_t c = 1; c < cascades; c++) {
|
||||
splitPositions[s++] = (float) c / cascades;
|
||||
splitPositions[s++] = float(c) / float(cascades);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ void LightManager::ShadowCascades::computeLogSplits(float splitPositions[3], uin
|
||||
cascades = max(cascades, (uint8_t) 4u);
|
||||
for (size_t c = 1; c < cascades; c++) {
|
||||
splitPositions[s++] =
|
||||
(near * std::pow(far / near, (float) c / cascades) - near) / (far - near);
|
||||
(near * std::pow(far / near, float(c) / float(cascades)) - near) / (far - near);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ RenderableManager::Builder& RenderableManager::Builder::morphing(size_t targetCo
|
||||
return *this;
|
||||
}
|
||||
|
||||
RenderableManager::Builder& RenderableManager::Builder::morphing(uint8_t level, size_t primitiveIndex,
|
||||
RenderableManager::Builder& RenderableManager::Builder::morphing(uint8_t, size_t primitiveIndex,
|
||||
MorphTargetBuffer* morphTargetBuffer, size_t offset, size_t count) noexcept {
|
||||
std::vector<Entry>& entries = mImpl->mEntries;
|
||||
if (primitiveIndex < entries.size()) {
|
||||
@@ -277,8 +277,8 @@ RenderableManager::Builder::Result RenderableManager::Builder::build(Engine& eng
|
||||
// this can't be an error because (1) those values are not immutable, so the caller
|
||||
// could fix later, and (2) the material's shader will work (i.e. compile), and
|
||||
// use the default values for this attribute, which maybe be acceptable.
|
||||
AttributeBitset declared = downcast(entry.vertices)->getDeclaredAttributes();
|
||||
AttributeBitset required = material->getRequiredAttributes();
|
||||
AttributeBitset const declared = downcast(entry.vertices)->getDeclaredAttributes();
|
||||
AttributeBitset const required = material->getRequiredAttributes();
|
||||
if ((declared & required) != required) {
|
||||
slog.w << "[entity=" << entity.getId() << ", primitive @ " << i
|
||||
<< "] missing required attributes ("
|
||||
@@ -326,7 +326,7 @@ void FRenderableManager::create(
|
||||
if (UTILS_UNLIKELY(manager.hasComponent(entity))) {
|
||||
destroy(entity);
|
||||
}
|
||||
Instance ci = manager.addComponent(entity);
|
||||
Instance const ci = manager.addComponent(entity);
|
||||
assert_invariant(ci);
|
||||
|
||||
if (ci) {
|
||||
@@ -460,7 +460,7 @@ void FRenderableManager::create(
|
||||
|
||||
// this destroys a single component from an entity
|
||||
void FRenderableManager::destroy(utils::Entity e) noexcept {
|
||||
Instance ci = getInstance(e);
|
||||
Instance const ci = getInstance(e);
|
||||
if (ci) {
|
||||
destroyComponent(ci);
|
||||
mManager.removeComponent(e);
|
||||
@@ -476,7 +476,7 @@ void FRenderableManager::terminate() noexcept {
|
||||
<< " leaked Renderable components" << io::endl;
|
||||
#endif
|
||||
while (!manager.empty()) {
|
||||
Instance ci = manager.end() - 1;
|
||||
Instance const ci = manager.end() - 1;
|
||||
destroyComponent(ci);
|
||||
manager.removeComponent(manager.getEntity(ci));
|
||||
}
|
||||
@@ -521,7 +521,7 @@ void FRenderableManager::destroyComponentPrimitives(
|
||||
delete[] primitives.data();
|
||||
}
|
||||
|
||||
void FRenderableManager::destroyComponentMorphTargets(FEngine& engine,
|
||||
void FRenderableManager::destroyComponentMorphTargets(FEngine&,
|
||||
utils::Slice<MorphTargets>& morphTargets) noexcept {
|
||||
delete[] morphTargets.data();
|
||||
}
|
||||
@@ -540,8 +540,8 @@ void FRenderableManager::setMaterialInstanceAt(Instance instance, uint8_t level,
|
||||
material->getName().c_str_safe(), (uint8_t)material->getFeatureLevel());
|
||||
|
||||
primitives[primitiveIndex].setMaterialInstance(mi);
|
||||
AttributeBitset required = material->getRequiredAttributes();
|
||||
AttributeBitset declared = primitives[primitiveIndex].getEnabledAttributes();
|
||||
AttributeBitset const required = material->getRequiredAttributes();
|
||||
AttributeBitset const declared = primitives[primitiveIndex].getEnabledAttributes();
|
||||
if (UTILS_UNLIKELY((declared & required) != required)) {
|
||||
slog.w << "[instance=" << instance.asValue() << ", primitive @ " << primitiveIndex
|
||||
<< "] missing required attributes ("
|
||||
@@ -610,7 +610,7 @@ void FRenderableManager::setGeometryAt(Instance instance, uint8_t level, size_t
|
||||
void FRenderableManager::setBones(Instance ci,
|
||||
Bone const* UTILS_RESTRICT transforms, size_t boneCount, size_t offset) {
|
||||
if (ci) {
|
||||
Bones& bones = mManager[ci].bones;
|
||||
Bones const& bones = mManager[ci].bones;
|
||||
|
||||
ASSERT_PRECONDITION(!bones.skinningBufferMode,
|
||||
"Disable skinning buffer mode to use this API");
|
||||
@@ -626,7 +626,7 @@ void FRenderableManager::setBones(Instance ci,
|
||||
void FRenderableManager::setBones(Instance ci,
|
||||
mat4f const* UTILS_RESTRICT transforms, size_t boneCount, size_t offset) {
|
||||
if (ci) {
|
||||
Bones& bones = mManager[ci].bones;
|
||||
Bones const& bones = mManager[ci].bones;
|
||||
|
||||
ASSERT_PRECONDITION(!bones.skinningBufferMode,
|
||||
"Disable skinning buffer mode to use this API");
|
||||
@@ -688,7 +688,7 @@ void FRenderableManager::setMorphWeights(Instance instance, float const* weights
|
||||
"Only %d morph targets are supported (count=%d, offset=%d)",
|
||||
CONFIG_MAX_MORPH_TARGET_COUNT, count, offset);
|
||||
|
||||
MorphWeights& morphWeights = mManager[instance].morphWeights;
|
||||
MorphWeights const& morphWeights = mManager[instance].morphWeights;
|
||||
if (morphWeights.handle) {
|
||||
updateMorphWeights(mEngine, morphWeights.handle, weights, count, offset);
|
||||
}
|
||||
@@ -702,7 +702,7 @@ void FRenderableManager::setMorphTargetBufferAt(Instance instance, uint8_t level
|
||||
if (instance) {
|
||||
assert_invariant(morphTargetBuffer);
|
||||
|
||||
MorphWeights& morphWeights = mManager[instance].morphWeights;
|
||||
MorphWeights const& morphWeights = mManager[instance].morphWeights;
|
||||
ASSERT_PRECONDITION(morphWeights.count == morphTargetBuffer->getCount(),
|
||||
"Only %d morph targets can be set (count=%d)",
|
||||
morphWeights.count, morphTargetBuffer->getCount());
|
||||
|
||||
@@ -44,7 +44,7 @@ static MaterialParser* createParser(Backend backend, const void* data, size_t si
|
||||
// unique_ptr so we don't leak MaterialParser on failures below
|
||||
auto materialParser = std::make_unique<MaterialParser>(backend, data, size);
|
||||
|
||||
MaterialParser::ParseResult materialResult = materialParser->parse();
|
||||
MaterialParser::ParseResult const materialResult = materialParser->parse();
|
||||
|
||||
if (backend == Backend::NOOP) {
|
||||
return materialParser.release();
|
||||
@@ -104,7 +104,7 @@ Material* Material::Builder::build(Engine& engine) {
|
||||
utils::bitset32 shaderModels;
|
||||
shaderModels.setValue(v);
|
||||
|
||||
ShaderModel shaderModel = downcast(engine).getShaderModel();
|
||||
ShaderModel const shaderModel = downcast(engine).getShaderModel();
|
||||
if (!shaderModels.test(static_cast<uint32_t>(shaderModel))) {
|
||||
CString name;
|
||||
materialParser->getName(&name);
|
||||
@@ -134,7 +134,7 @@ FMaterial::FMaterial(FEngine& engine, const Material::Builder& builder)
|
||||
MaterialParser* parser = builder->mMaterialParser;
|
||||
mMaterialParser = parser;
|
||||
|
||||
UTILS_UNUSED_IN_RELEASE bool nameOk = parser->getName(&mName);
|
||||
UTILS_UNUSED_IN_RELEASE bool const nameOk = parser->getName(&mName);
|
||||
assert_invariant(nameOk);
|
||||
|
||||
uint8_t featureLevel = 1;
|
||||
@@ -378,8 +378,8 @@ void FMaterial::getSurfaceProgramSlow(Variant variant) const noexcept {
|
||||
|
||||
assert_invariant(!Variant::isReserved(variant));
|
||||
|
||||
Variant vertexVariant = Variant::filterVariantVertex(variant);
|
||||
Variant fragmentVariant = Variant::filterVariantFragment(variant);
|
||||
Variant const vertexVariant = Variant::filterVariantVertex(variant);
|
||||
Variant const fragmentVariant = Variant::filterVariantFragment(variant);
|
||||
|
||||
Program pb{ getProgramBuilderWithVariants(variant, vertexVariant, fragmentVariant) };
|
||||
createAndCacheProgram(std::move(pb), variant);
|
||||
@@ -403,7 +403,7 @@ Program FMaterial::getProgramBuilderWithVariants(
|
||||
|
||||
ShaderContent& vsBuilder = mEngine.getVertexShaderContent();
|
||||
|
||||
UTILS_UNUSED_IN_RELEASE bool vsOK = mMaterialParser->getShader(vsBuilder, sm,
|
||||
UTILS_UNUSED_IN_RELEASE bool const vsOK = mMaterialParser->getShader(vsBuilder, sm,
|
||||
vertexVariant, ShaderStage::VERTEX);
|
||||
|
||||
ASSERT_POSTCONDITION(isNoop || (vsOK && !vsBuilder.empty()),
|
||||
@@ -417,7 +417,7 @@ Program FMaterial::getProgramBuilderWithVariants(
|
||||
|
||||
ShaderContent& fsBuilder = mEngine.getFragmentShaderContent();
|
||||
|
||||
UTILS_UNUSED_IN_RELEASE bool fsOK = mMaterialParser->getShader(fsBuilder, sm,
|
||||
UTILS_UNUSED_IN_RELEASE bool const fsOK = mMaterialParser->getShader(fsBuilder, sm,
|
||||
fragmentVariant, ShaderStage::FRAGMENT);
|
||||
|
||||
ASSERT_POSTCONDITION(isNoop || (fsOK && !fsBuilder.empty()),
|
||||
@@ -437,12 +437,12 @@ Program FMaterial::getProgramBuilderWithVariants(
|
||||
|
||||
UTILS_NOUNROLL
|
||||
for (size_t i = 0; i < Enum::count<SamplerBindingPoints>(); i++) {
|
||||
SamplerBindingPoints bindingPoint = (SamplerBindingPoints)i;
|
||||
SamplerBindingPoints const bindingPoint = (SamplerBindingPoints)i;
|
||||
auto const& info = mSamplerGroupBindingInfoList[i];
|
||||
if (info.count) {
|
||||
std::array<Program::Sampler, backend::MAX_SAMPLER_COUNT> samplers{};
|
||||
for (size_t j = 0, c = info.count; j < c; ++j) {
|
||||
uint8_t binding = info.bindingOffset + j;
|
||||
uint8_t const binding = info.bindingOffset + j;
|
||||
samplers[j] = { mSamplerBindingToNameMap[binding], binding };
|
||||
}
|
||||
program.setSamplerGroup(+bindingPoint, info.shaderStageFlags,
|
||||
@@ -469,7 +469,7 @@ size_t FMaterial::getParameters(ParameterInfo* parameters, size_t count) const n
|
||||
|
||||
const auto& uniforms = mUniformInterfaceBlock.getFieldInfoList();
|
||||
size_t i = 0;
|
||||
size_t uniformCount = std::min(count, size_t(uniforms.size()));
|
||||
size_t const uniformCount = std::min(count, size_t(uniforms.size()));
|
||||
for ( ; i < uniformCount; i++) {
|
||||
ParameterInfo& info = parameters[i];
|
||||
const auto& uniformInfo = uniforms[i];
|
||||
@@ -482,7 +482,7 @@ size_t FMaterial::getParameters(ParameterInfo* parameters, size_t count) const n
|
||||
}
|
||||
|
||||
const auto& samplers = mSamplerInterfaceBlock.getSamplerInfoList();
|
||||
size_t samplerCount = samplers.size();
|
||||
size_t const samplerCount = samplers.size();
|
||||
for (size_t j = 0; i < count && j < samplerCount; i++, j++) {
|
||||
ParameterInfo& info = parameters[i];
|
||||
const auto& samplerInfo = samplers[j];
|
||||
@@ -502,7 +502,6 @@ size_t FMaterial::getParameters(ParameterInfo* parameters, size_t count) const n
|
||||
info.subpassType = mSubpassInfo.type;
|
||||
info.count = 1;
|
||||
info.precision = mSubpassInfo.precision;
|
||||
i++;
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
@@ -173,7 +173,7 @@ void FMaterialInstance::commitSlow(DriverApi& driver) const {
|
||||
|
||||
void FMaterialInstance::setParameter(std::string_view name,
|
||||
backend::Handle<backend::HwTexture> texture, backend::SamplerParams params) noexcept {
|
||||
size_t index = mMaterial->getSamplerInterfaceBlock().getSamplerInfo(name)->offset;
|
||||
size_t const index = mMaterial->getSamplerInterfaceBlock().getSamplerInfo(name)->offset;
|
||||
mSamplers.setSampler(index, { texture, params });
|
||||
}
|
||||
|
||||
@@ -184,8 +184,8 @@ void FMaterialInstance::setParameterImpl(std::string_view name,
|
||||
// Per GLES3.x specification, depth texture can't be filtered unless in compare mode.
|
||||
if (texture && isDepthFormat(texture->getFormat())) {
|
||||
if (sampler.getCompareMode() == SamplerCompareMode::NONE) {
|
||||
SamplerMinFilter minFilter = sampler.getMinFilter();
|
||||
SamplerMagFilter magFilter = sampler.getMagFilter();
|
||||
SamplerMinFilter const minFilter = sampler.getMinFilter();
|
||||
SamplerMagFilter const magFilter = sampler.getMagFilter();
|
||||
if (magFilter == SamplerMagFilter::LINEAR ||
|
||||
minFilter == SamplerMinFilter::LINEAR ||
|
||||
minFilter == SamplerMinFilter::LINEAR_MIPMAP_LINEAR ||
|
||||
|
||||
@@ -220,7 +220,7 @@ void FMorphTargetBuffer::updateDataAt(backend::DriverApi& driver,
|
||||
// 'out' buffer is going to be used up to 3 times, so for simplicity we use a shared_buffer
|
||||
// to manage its lifetime. One side effect of this is that the callbacks below will allocate
|
||||
// a small object on the heap.
|
||||
std::shared_ptr<void> allocation((void*)out, ::free);
|
||||
std::shared_ptr<void> const allocation((void*)out, ::free);
|
||||
|
||||
// Note: because the texture width is up to 2048, we're expecting that most of the time
|
||||
// only a single texture update call will be necessary (i.e. that there are no more
|
||||
|
||||
@@ -94,7 +94,7 @@ FSkybox::FSkybox(FEngine& engine, const Builder& builder) noexcept
|
||||
FMaterial const* material = engine.getSkyboxMaterial();
|
||||
mSkyboxMaterialInstance = material->createInstance("Skybox");
|
||||
|
||||
TextureSampler sampler(TextureSampler::MagFilter::LINEAR, TextureSampler::WrapMode::REPEAT);
|
||||
TextureSampler const sampler(TextureSampler::MagFilter::LINEAR, TextureSampler::WrapMode::REPEAT);
|
||||
auto *pInstance = static_cast<MaterialInstance*>(mSkyboxMaterialInstance);
|
||||
FTexture const* texture = mSkyboxTexture ? mSkyboxTexture : engine.getDummyCubemap();
|
||||
pInstance->setParameter("skybox", texture, sampler);
|
||||
|
||||
@@ -401,8 +401,8 @@ void FTexture::generateMipmaps(FEngine& engine) const noexcept {
|
||||
// Perform a blit for all miplevels down to 1x1.
|
||||
backend::Handle<backend::HwRenderTarget> dstrth;
|
||||
do {
|
||||
uint32_t dstw = std::max(srcw >> 1u, 1u);
|
||||
uint32_t dsth = std::max(srch >> 1u, 1u);
|
||||
uint32_t const dstw = std::max(srcw >> 1u, 1u);
|
||||
uint32_t const dsth = std::max(srch >> 1u, 1u);
|
||||
proto.level = level++;
|
||||
dstrth = driver.createRenderTarget(
|
||||
TargetBufferFlags::COLOR, dstw, dsth, mSampleCount, proto, {}, {});
|
||||
@@ -500,7 +500,7 @@ void FTexture::generatePrefilterMipmap(FEngine& engine,
|
||||
"reflections texture cannot be compressed");
|
||||
|
||||
|
||||
PrefilterOptions defaultOptions;
|
||||
PrefilterOptions const defaultOptions;
|
||||
options = options ? options : &defaultOptions;
|
||||
|
||||
JobSystem& js = engine.getJobSystem();
|
||||
@@ -558,7 +558,7 @@ void FTexture::generatePrefilterMipmap(FEngine& engine,
|
||||
Image temp;
|
||||
Cubemap cml = CubemapUtils::create(temp, size);
|
||||
for (size_t j = 0; j < 6; j++) {
|
||||
Cubemap::Face face = (Cubemap::Face)j;
|
||||
Cubemap::Face const face = (Cubemap::Face)j;
|
||||
Image const& image = cml.getImageForFace(face);
|
||||
for (size_t y = 0; y < size; y++) {
|
||||
Cubemap::Texel* out = (Cubemap::Texel*)image.getPixelRef(0, y);
|
||||
@@ -584,10 +584,10 @@ void FTexture::generatePrefilterMipmap(FEngine& engine,
|
||||
for (size_t x = 0; x < size; x++, out++, src++) {
|
||||
using fp10 = fp<0, 5, 5>;
|
||||
using fp11 = fp<0, 5, 6>;
|
||||
fp11 r{ uint16_t( *src & 0x7FFu) };
|
||||
fp11 g{ uint16_t((*src >> 11u) & 0x7FFu) };
|
||||
fp10 b{ uint16_t((*src >> 22u) & 0x3FFu) };
|
||||
Cubemap::Texel texel{ fp11::tof(r), fp11::tof(g), fp10::tof(b) };
|
||||
fp11 const r{ uint16_t( *src & 0x7FFu) };
|
||||
fp11 const g{ uint16_t((*src >> 11u) & 0x7FFu) };
|
||||
fp10 const b{ uint16_t((*src >> 22u) & 0x3FFu) };
|
||||
Cubemap::Texel const texel{ fp11::tof(r), fp11::tof(g), fp10::tof(b) };
|
||||
Cubemap::writeAt(out, texel);
|
||||
}
|
||||
}
|
||||
@@ -614,12 +614,12 @@ void FTexture::generatePrefilterMipmap(FEngine& engine,
|
||||
|
||||
// Finally generate each pre-filtered mipmap level
|
||||
const size_t baseExp = ctz(size);
|
||||
size_t numSamples = options->sampleCount;
|
||||
size_t const numSamples = options->sampleCount;
|
||||
const size_t numLevels = baseExp + 1;
|
||||
for (ssize_t i = baseExp; i >= 0; --i) {
|
||||
for (ssize_t i = (ssize_t)baseExp; i >= 0; --i) {
|
||||
const size_t dim = 1U << i;
|
||||
const size_t level = baseExp - i;
|
||||
const float lod = saturate(level / (numLevels - 1.0f));
|
||||
const float lod = saturate(float(level) / float(numLevels - 1));
|
||||
const float linearRoughness = lod * lod;
|
||||
|
||||
Image image;
|
||||
@@ -627,11 +627,11 @@ void FTexture::generatePrefilterMipmap(FEngine& engine,
|
||||
CubemapIBL::roughnessFilter(js, dst, { levels.begin(), uint32_t(levels.size()) },
|
||||
linearRoughness, numSamples, mirror, true);
|
||||
|
||||
Texture::PixelBufferDescriptor pbd(image.getData(), image.getSize(),
|
||||
Texture::PixelBufferDescriptor const pbd(image.getData(), image.getSize(),
|
||||
Texture::PixelBufferDescriptor::PixelDataFormat::RGB,
|
||||
Texture::PixelBufferDescriptor::PixelDataType::FLOAT, 1, 0, 0, image.getStride());
|
||||
|
||||
uintptr_t base = uintptr_t(image.getData());
|
||||
uintptr_t const base = uintptr_t(image.getData());
|
||||
for (size_t j = 0; j < 6; j++) {
|
||||
Image const& faceImage = dst.getImageForFace((Cubemap::Face)j);
|
||||
auto offset = uintptr_t(faceImage.getData()) - base;
|
||||
|
||||
@@ -67,7 +67,7 @@ VertexBuffer::Builder& VertexBuffer::Builder::attribute(VertexAttribute attribut
|
||||
uint32_t byteOffset,
|
||||
uint8_t byteStride) noexcept {
|
||||
|
||||
size_t attributeSize = Driver::getElementTypeSize(attributeType);
|
||||
size_t const attributeSize = Driver::getElementTypeSize(attributeType);
|
||||
if (byteStride == 0) {
|
||||
byteStride = (uint8_t)attributeSize;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ FVertexBuffer::FVertexBuffer(FEngine& engine, const VertexBuffer::Builder& build
|
||||
std::copy(std::begin(builder->mAttributes), std::end(builder->mAttributes), mAttributes.begin());
|
||||
|
||||
mDeclaredAttributes = builder->mDeclaredAttributes;
|
||||
uint8_t attributeCount = (uint8_t) mDeclaredAttributes.count();
|
||||
uint8_t const attributeCount = (uint8_t)mDeclaredAttributes.count();
|
||||
|
||||
AttributeArray attributeArray;
|
||||
|
||||
@@ -190,7 +190,7 @@ FVertexBuffer::FVertexBuffer(FEngine& engine, const VertexBuffer::Builder& build
|
||||
#pragma nounroll
|
||||
for (size_t i = 0; i < MAX_VERTEX_BUFFER_COUNT; ++i) {
|
||||
if (bufferSizes[i] > 0) {
|
||||
BufferObjectHandle bo = driver.createBufferObject(bufferSizes[i],
|
||||
BufferObjectHandle const bo = driver.createBufferObject(bufferSizes[i],
|
||||
backend::BufferObjectBinding::VERTEX, backend::BufferUsage::STATIC);
|
||||
driver.setVertexBufferObject(mHandle, i, bo);
|
||||
mBufferObjects[i] = bo;
|
||||
@@ -202,7 +202,7 @@ FVertexBuffer::FVertexBuffer(FEngine& engine, const VertexBuffer::Builder& build
|
||||
void FVertexBuffer::terminate(FEngine& engine) {
|
||||
FEngine::DriverApi& driver = engine.getDriverApi();
|
||||
if (!mBufferObjectsEnabled) {
|
||||
for (BufferObjectHandle bo : mBufferObjects) {
|
||||
for (BufferObjectHandle const bo : mBufferObjects) {
|
||||
driver.destroyBufferObject(bo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <filament/TextureSampler.h>
|
||||
#include <filament/View.h>
|
||||
|
||||
#include <private/filament/SibStructs.h>
|
||||
#include <private/filament/UibStructs.h>
|
||||
|
||||
#include <utils/Profiler.h>
|
||||
@@ -180,8 +179,8 @@ float2 FView::updateScale(FEngine& engine,
|
||||
const float dt = 1.0f; // we don't really need dt here, setting it to 1, means our parameters are in "frames"
|
||||
const float target = (1000.0f * float(frameRateOptions.interval)) / displayInfo.refreshRate;
|
||||
const float targetWithHeadroom = target * (1.0f - frameRateOptions.headRoomRatio);
|
||||
float measured = duration<float, std::milli>{ info.denoisedFrameTime }.count();
|
||||
float out = mPidController.update(measured / targetWithHeadroom, 1.0f, dt);
|
||||
float const measured = duration<float, std::milli>{ info.denoisedFrameTime }.count();
|
||||
float const out = mPidController.update(measured / targetWithHeadroom, 1.0f, dt);
|
||||
|
||||
// maps pid command to a scale (absolute or relative, see below)
|
||||
const float command = out < 0.0f ? (1.0f / (1.0f - out)) : (1.0f + out);
|
||||
@@ -303,7 +302,7 @@ void FView::prepareShadowing(FEngine& engine, FScene::RenderableSoa& renderableD
|
||||
// when we get here all the lights should be visible
|
||||
assert_invariant(lightData.elementAt<FScene::VISIBILITY>(l));
|
||||
|
||||
FLightManager::Instance li = lightData.elementAt<FScene::LIGHT_INSTANCE>(l);
|
||||
FLightManager::Instance const li = lightData.elementAt<FScene::LIGHT_INSTANCE>(l);
|
||||
|
||||
if (UTILS_LIKELY(!li)) {
|
||||
continue; // invalid instance
|
||||
@@ -762,7 +761,7 @@ void FView::prepareVisibleRenderables(JobSystem& js,
|
||||
}
|
||||
}
|
||||
|
||||
void FView::cullRenderables(JobSystem& js,
|
||||
void FView::cullRenderables(JobSystem&,
|
||||
FScene::RenderableSoa& renderableData, Frustum const& frustum, size_t bit) noexcept {
|
||||
SYSTRACE_CALL();
|
||||
|
||||
@@ -806,7 +805,7 @@ void FView::prepareVisibleLights(FLightManager const& lcm, ArenaScope& rootArena
|
||||
size_t visibleLightCount = FScene::DIRECTIONAL_LIGHTS_COUNT;
|
||||
// skip directional light
|
||||
for (size_t i = FScene::DIRECTIONAL_LIGHTS_COUNT; i < lightData.size(); i++) {
|
||||
FLightManager::Instance li = instanceArray[i];
|
||||
FLightManager::Instance const li = instanceArray[i];
|
||||
if (visibleArray[i]) {
|
||||
if (!lcm.isLightCaster(li)) {
|
||||
visibleArray[i] = 0;
|
||||
@@ -902,8 +901,8 @@ inline void FView::computeLightCameraDistances(
|
||||
void FView::updatePrimitivesLod(FEngine& engine, const CameraInfo&,
|
||||
FScene::RenderableSoa& renderableData, Range visible) noexcept {
|
||||
FRenderableManager const& rcm = engine.getRenderableManager();
|
||||
for (uint32_t index : visible) {
|
||||
uint8_t level = 0; // TODO: pick the proper level of detail
|
||||
for (uint32_t const index : visible) {
|
||||
uint8_t const level = 0; // TODO: pick the proper level of detail
|
||||
auto ri = renderableData.elementAt<FScene::RENDERABLE_INSTANCE>(index);
|
||||
renderableData.elementAt<FScene::PRIMITIVES>(index) = rcm.getRenderPrimitives(ri, level);
|
||||
}
|
||||
@@ -944,10 +943,10 @@ void FView::executePickingQueries(backend::DriverApi& driver,
|
||||
const uint32_t x = uint32_t(float(pQuery->x) * (scale * mScale.x));
|
||||
const uint32_t y = uint32_t(float(pQuery->y) * (scale * mScale.y));
|
||||
driver.readPixels(handle, x, y, 1, 1, {
|
||||
&pQuery->result.renderable, 4*4, // 4*uint
|
||||
&pQuery->result.renderable, 4 * 4, // 4*uint
|
||||
// FIXME: RGBA_INTEGER is guaranteed to work. R_INTEGER must be queried.
|
||||
backend::PixelDataFormat::RG_INTEGER, backend::PixelDataType::UINT,
|
||||
pQuery->handler, [](void* buffer, size_t size, void* user) {
|
||||
pQuery->handler, [](void*, size_t, void* user) {
|
||||
FPickingQuery* pQuery = static_cast<FPickingQuery*>(user);
|
||||
pQuery->result.fragCoords = {
|
||||
pQuery->x, pQuery->y,float(1.0 - pQuery->result.depth) };
|
||||
|
||||
@@ -51,7 +51,7 @@ uint32_t FrameGraph::Builder::declareRenderPass(const char* name,
|
||||
FrameGraphId<FrameGraphTexture> FrameGraph::Builder::declareRenderPass(
|
||||
FrameGraphId<FrameGraphTexture> color, uint32_t* index) {
|
||||
color = write(color);
|
||||
uint32_t id = declareRenderPass(getName(color),
|
||||
uint32_t const id = declareRenderPass(getName(color),
|
||||
{ .attachments = { .color = { color }}});
|
||||
if (index) *index = id;
|
||||
return color;
|
||||
@@ -238,10 +238,10 @@ FrameGraphHandle FrameGraph::createNewVersion(FrameGraphHandle handle) noexcept
|
||||
assert_invariant(handle);
|
||||
ResourceNode* const node = getActiveResourceNode(handle);
|
||||
assert_invariant(node);
|
||||
FrameGraphHandle parent = node->getParentHandle();
|
||||
FrameGraphHandle const parent = node->getParentHandle();
|
||||
ResourceSlot& slot = getResourceSlot(handle);
|
||||
slot.version = ++handle.version; // increase the parent's version
|
||||
slot.nid = mResourceNodes.size(); // create the new parent node
|
||||
slot.nid = (ResourceSlot::Index)mResourceNodes.size(); // create the new parent node
|
||||
ResourceNode* newNode = mArena.make<ResourceNode>(*this, handle, parent);
|
||||
mResourceNodes.push_back(newNode);
|
||||
return handle;
|
||||
@@ -253,7 +253,7 @@ ResourceNode* FrameGraph::createNewVersionForSubresourceIfNeeded(ResourceNode* n
|
||||
// if we don't already have a new ResourceNode for this resource, create one.
|
||||
// we keep the old ResourceNode index, so we can direct all the reads to it.
|
||||
slot.sid = slot.nid; // record the current ResourceNode of the parent
|
||||
slot.nid = mResourceNodes.size(); // create the new parent node
|
||||
slot.nid = (ResourceSlot::Index)mResourceNodes.size(); // create the new parent node
|
||||
node = mArena.make<ResourceNode>(*this, node->resourceHandle, node->getParentHandle());
|
||||
mResourceNodes.push_back(node);
|
||||
}
|
||||
@@ -266,10 +266,10 @@ FrameGraphHandle FrameGraph::addResourceInternal(VirtualResource* resource) noex
|
||||
|
||||
FrameGraphHandle FrameGraph::addSubResourceInternal(FrameGraphHandle parent,
|
||||
VirtualResource* resource) noexcept {
|
||||
FrameGraphHandle handle(mResourceSlots.size());
|
||||
FrameGraphHandle const handle(mResourceSlots.size());
|
||||
ResourceSlot& slot = mResourceSlots.emplace_back();
|
||||
slot.rid = mResources.size();
|
||||
slot.nid = mResourceNodes.size();
|
||||
slot.rid = (ResourceSlot::Index)mResources.size();
|
||||
slot.nid = (ResourceSlot::Index)mResourceNodes.size();
|
||||
mResources.push_back(resource);
|
||||
ResourceNode* pNode = mArena.make<ResourceNode>(*this, handle, parent);
|
||||
mResourceNodes.push_back(pNode);
|
||||
@@ -285,7 +285,7 @@ FrameGraphHandle FrameGraph::readInternal(FrameGraphHandle handle, PassNode* pas
|
||||
ResourceNode* const node = getActiveResourceNode(handle);
|
||||
|
||||
// Check preconditions
|
||||
bool passAlreadyAWriter = node->hasWriteFrom(passNode);
|
||||
bool const passAlreadyAWriter = node->hasWriteFrom(passNode);
|
||||
ASSERT_PRECONDITION(!passAlreadyAWriter,
|
||||
"Pass \"%s\" already writes to \"%s\"",
|
||||
passNode->getName(), node->getName());
|
||||
@@ -303,7 +303,7 @@ FrameGraphHandle FrameGraph::readInternal(FrameGraphHandle handle, PassNode* pas
|
||||
// node to the subresource -- but we may have two parent nodes, one for reads and
|
||||
// one for writes, so we need to use the one for reads.
|
||||
auto* parentNode = node->getParentNode();
|
||||
ResourceSlot& slot = getResourceSlot(parentNode->resourceHandle);
|
||||
ResourceSlot const& slot = getResourceSlot(parentNode->resourceHandle);
|
||||
if (slot.sid >= 0) {
|
||||
// we have a parent's node for reads, use that one
|
||||
parentNode = mResourceNodes[slot.sid];
|
||||
@@ -314,7 +314,7 @@ FrameGraphHandle FrameGraph::readInternal(FrameGraphHandle handle, PassNode* pas
|
||||
// resource is a parent of some subresource, and it might exist as a version for
|
||||
// writing, in this case we need to add a dependency from its "read" version to
|
||||
// itself.
|
||||
ResourceSlot& slot = getResourceSlot(handle);
|
||||
ResourceSlot const& slot = getResourceSlot(handle);
|
||||
if (slot.sid >= 0) {
|
||||
node->setParentReadDependency(mResourceNodes[slot.sid]);
|
||||
}
|
||||
@@ -440,7 +440,7 @@ bool FrameGraph::isValid(FrameGraphHandle handle) const {
|
||||
if (!handle.isInitialized()) {
|
||||
return false;
|
||||
}
|
||||
ResourceSlot slot = getResourceSlot(handle);
|
||||
ResourceSlot const& slot = getResourceSlot(handle);
|
||||
if (handle.version != slot.version) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -76,13 +76,13 @@ void RenderPassNode::execute(FrameGraphResources const& resources, DriverApi& dr
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t RenderPassNode::declareRenderTarget(FrameGraph& fg, FrameGraph::Builder& builder,
|
||||
uint32_t RenderPassNode::declareRenderTarget(FrameGraph& fg, FrameGraph::Builder&,
|
||||
const char* name, FrameGraphRenderPass::Descriptor const& descriptor) {
|
||||
|
||||
RenderPassData data;
|
||||
data.name = name;
|
||||
data.descriptor = descriptor;
|
||||
FrameGraphRenderPass::Attachments& attachments = data.descriptor.attachments;
|
||||
FrameGraphRenderPass::Attachments const& attachments = data.descriptor.attachments;
|
||||
|
||||
// retrieve the ResourceNode of the attachments coming to us -- this will be used later
|
||||
// to compute the discard flags.
|
||||
@@ -118,7 +118,7 @@ uint32_t RenderPassNode::declareRenderTarget(FrameGraph& fg, FrameGraph::Builder
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t id = mRenderTargetData.size();
|
||||
uint32_t const id = mRenderTargetData.size();
|
||||
mRenderTargetData.push_back(data);
|
||||
return id;
|
||||
}
|
||||
@@ -201,8 +201,8 @@ void RenderPassNode::resolve() noexcept {
|
||||
|
||||
// of all attachments size matches there are no ambiguity about the RT size.
|
||||
// if they don't match however, we select a size that will accommodate all attachments.
|
||||
uint32_t width = maxWidth;
|
||||
uint32_t height = maxHeight;
|
||||
uint32_t const width = maxWidth;
|
||||
uint32_t const height = maxHeight;
|
||||
|
||||
// Update the descriptor if no size was specified (auto mode)
|
||||
if (!rt.descriptor.viewport.width) {
|
||||
@@ -277,7 +277,7 @@ void RenderPassNode::RenderPassData::devirtualize(FrameGraph& fg,
|
||||
}
|
||||
|
||||
void RenderPassNode::RenderPassData::destroy(
|
||||
ResourceAllocatorInterface& resourceAllocator) noexcept {
|
||||
ResourceAllocatorInterface& resourceAllocator) const noexcept {
|
||||
if (UTILS_LIKELY(!imported)) {
|
||||
resourceAllocator.destroyRenderTarget(backend.target);
|
||||
}
|
||||
@@ -291,9 +291,9 @@ utils::CString RenderPassNode::graphvizify() const noexcept {
|
||||
#ifndef NDEBUG
|
||||
std::string s;
|
||||
|
||||
uint32_t id = getId();
|
||||
uint32_t const id = getId();
|
||||
const char* const nodeName = getName();
|
||||
uint32_t refCount = getRefCount();
|
||||
uint32_t const refCount = getRefCount();
|
||||
|
||||
s.append("[label=\"");
|
||||
s.append(nodeName);
|
||||
@@ -339,7 +339,7 @@ utils::CString PresentPassNode::graphvizify() const noexcept {
|
||||
#ifndef NDEBUG
|
||||
std::string s;
|
||||
s.reserve(128);
|
||||
uint32_t id = getId();
|
||||
uint32_t const id = getId();
|
||||
s.append("[label=\"Present , id: ");
|
||||
s.append(std::to_string(id));
|
||||
s.append("\", style=filled, fillcolor=red3]");
|
||||
|
||||
@@ -80,7 +80,7 @@ bool ResourceNode::hasActiveReaders() const noexcept {
|
||||
|
||||
bool ResourceNode::hasActiveWriters() const noexcept {
|
||||
// here we don't use mReaderPasses because this wouldn't account for subresources
|
||||
DependencyGraph& dependencyGraph = mFrameGraph.getGraph();
|
||||
DependencyGraph const& dependencyGraph = mFrameGraph.getGraph();
|
||||
auto const& writers = dependencyGraph.getIncomingEdges(this);
|
||||
// writers are not culled by definition if we're not culled ourselves
|
||||
return !writers.empty();
|
||||
@@ -135,7 +135,7 @@ utils::CString ResourceNode::graphvizify() const noexcept {
|
||||
std::string s;
|
||||
s.reserve(128);
|
||||
|
||||
uint32_t id = getId();
|
||||
uint32_t const id = getId();
|
||||
const char* const nodeName = getName();
|
||||
VirtualResource* const pResource = mFrameGraph.getResource(resourceHandle);
|
||||
FrameGraph::ResourceSlot const& slot = mFrameGraph.getResourceSlot(resourceHandle);
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
} backend;
|
||||
|
||||
void devirtualize(FrameGraph& fg, ResourceAllocatorInterface& resourceAllocator) noexcept;
|
||||
void destroy(ResourceAllocatorInterface& resourceAllocator) noexcept;
|
||||
void destroy(ResourceAllocatorInterface& resourceAllocator) const noexcept;
|
||||
};
|
||||
|
||||
RenderPassNode(FrameGraph& fg, const char* name, FrameGraphPassBase* base) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user