Estella
0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
LightStore.cpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
7
#include "
./LightStore.hpp
"
8
9
#include "
../rhi/GfxDevice.hpp
"
10
#include "
../rhi/GfxEnums.hpp
"
11
12
namespace
esengine
{
13
14
void
LightStore::uploadAndBind
() {
15
if
(!device_)
return
;
16
17
if
(ubo_ ==
BufferHandle::Invalid
) {
18
ubo_ = device_->createBuffer(
19
{
GfxBufferUsage::Uniform
,
static_cast<
u32
>
(
sizeof
(
LightConstants
)),
/*dynamic=*/
true
},
20
GfxContent::retained
(), &data_);
21
dirty_ =
false
;
22
}
else
if
(dirty_) {
23
device_->updateBuffer(ubo_, 0, &data_,
sizeof
(
LightConstants
));
24
dirty_ =
false
;
25
}
26
device_->setUniformBuffer(
LIGHT_CONSTANTS_BINDING
, ubo_);
27
}
28
29
void
LightStore::free
() {
30
if
(ubo_ !=
BufferHandle::Invalid
&& device_) {
31
device_->deleteBuffer(ubo_);
32
ubo_ =
BufferHandle::Invalid
;
33
}
34
dirty_ =
true
;
35
}
36
37
}
// namespace esengine
GfxDevice.hpp
Abstract graphics device interface.
GfxEnums.hpp
Backend-agnostic graphics enumerations.
LightStore.hpp
Engine-side 2D light registry — the per-frame LightConstants UBO and its CPU mirror.
esengine::GfxContent::retained
static constexpr GfxContent retained()
Definition
GfxContent.hpp:33
esengine::LightStore::free
void free()
Frees the GPU UBO. Call while the device is still valid (RenderContext::shutdown).
Definition
LightStore.cpp:29
esengine::LightStore::uploadAndBind
void uploadAndBind()
Definition
LightStore.cpp:14
esengine
Definition
EasingFunctions.hpp:10
esengine::GfxBufferUsage::Uniform
@ Uniform
Definition
GfxEnums.hpp:75
esengine::LIGHT_CONSTANTS_BINDING
constexpr u32 LIGHT_CONSTANTS_BINDING
Indexed UBO binding point for the per-frame LightConstants block.
Definition
LightConstants.hpp:26
esengine::BufferHandle::Invalid
@ Invalid
Definition
GfxEnums.hpp:35
esengine::u32
std::uint32_t u32
Unsigned 32-bit integer.
Definition
Types.hpp:45
esengine::LightConstants
CPU mirror of the GLSL LightConstants block (std140).
Definition
LightConstants.hpp:141
src
esengine
renderer
store
LightStore.cpp
Generated by
1.15.0