52 gl46core::GLenum indexFormat = gl46core::GL_NONE;
58 if ( idxBuffer._idxBufferSync !=
nullptr )
60 gl46core::glWaitSync( idxBuffer._idxBufferSync, gl46core::UnusedMask::GL_UNUSED_BIT, gl46core::GL_TIMEOUT_IGNORED );
68 indexFormat = idxBuffer._data.count > 0u ? (idxBuffer._data.smallIndices ? gl46core::GL_UNSIGNED_SHORT : gl46core::GL_UNSIGNED_INT) : gl46core::GL_NONE;
90 if ( idxBuffer._data.id == indices.
id )
104 if ( indices.
count == 0u ||
113 if ( indices.
count == 0u )
119 const size_t elementSize = indices.
smallIndices ?
sizeof( gl46core::GLushort ) :
sizeof( gl46core::GLuint );
120 const gl46core::GLenum usage = indices.
dynamic ? gl46core::GL_STREAM_DRAW : gl46core::GL_STATIC_DRAW;
123 impl->
_data = indices;
130 const size_t range = indices.
count * elementSize;
137 const U32*
const dataIn =
reinterpret_cast<U32*
>(data);
138 for (
size_t i = 0u; i < indices.
count; ++i )
147 gl46core::glNamedBufferData( impl->
_handle, range, data, usage);
151 gl46core::glInvalidateBufferSubData( impl->
_handle, 0u, range );
152 gl46core::glNamedBufferSubData( impl->
_handle, 0u, range, data );
187 if ( impl ==
nullptr )
197 implParams.
_dataSize = bufferSizeInBytes * ringSizeFactor;
198 implParams.
_target = gl46core::GL_ARRAY_BUFFER;
201 const size_t elementStride = params.
_elementStride == SetBufferParams::INVALID_ELEMENT_STRIDE
208 if ( impl->
_buffer !=
nullptr && impl->
_buffer->params() == implParams )
216 for (
U32 i = 1u; i < ringSizeFactor; ++i )
218 ret = impl->
_buffer->writeOrClearBytes(i * bufferSizeInBytes,
230 const U32 elementCountOffset,
231 const U32 elementCountRange,
239 if ( bufferImpl._bindConfig._bufferIdx == buffer )
246 DIVIDE_ASSERT( impl !=
nullptr &&
"glGenericVertexData error: set buffer called for invalid buffer index!" );
251 const size_t dataCurrentSizeInBytes = elementCountRange * bufferParams.
_elementSize;
253 size_t offsetInBytes = elementCountOffset * bufferParams.
_elementSize;
262 impl->
_buffer->writeOrClearBytes( offsetInBytes, dataCurrentSizeInBytes, data );
266 .
_range = { offsetInBytes, dataCurrentSizeInBytes },
279 if ( bufferImpl._bindConfig._bufferIdx == bindConfig._bufferIdx )
286 if ( impl ==
nullptr ) [[unlikely]]
292 size_t offsetInBytes = impl->
_buffer->memoryBlock()._offset;
301 impl->
_buffer->memoryBlock()._bufferHandle,
#define PROFILE_SCOPE_AUTO(CATEGORY)
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
static void DestroyFenceSync(gl46core::GLsync &sync)
static gl46core::GLsync CreateFenceSync()
static GLStateTracker & GetStateTracker() noexcept
U16 queueLength() const noexcept
I32 queueIndex() const noexcept
SharedMutex _idxBufferLock
void draw(const GenericDrawCommand &command, VDIUserData *data) override
Submit a draw command to the GPU using this object and the specified command.
BufferLock updateBuffer(U32 buffer, U32 elementCountOffset, U32 elementCountRange, bufferPtr data) override
Update the elementCount worth of data contained in the buffer starting from elementCountOffset size o...
eastl::fixed_vector< IndexBufferEntry, 1, true > _idxBuffers
glGenericVertexData(GFXDevice &context, U16 ringBufferLength, const std::string_view name)
BufferLock setBuffer(const SetBufferParams ¶ms) override
Specify the structure and data of the given buffer.
void bindBufferInternal(const SetBufferParams::BufferBindConfig &bindConfig)
eastl::fixed_vector< GenericBufferImpl, 1, true > _bufferObjects
void reset() override
Also clears GPU memory.
BufferLock setIndexBuffer(const IndexBuffer &indices) override
void SubmitRenderCommand(const GenericDrawCommand &drawCommand, const gl46core::GLenum internalFormat)
Note: If internal format is not GL_NONE, an indexed draw is issued!
void createBuffer(gl46core::GLuint &bufferIdOut, const char *name)
void freeBuffer(gl46core::GLuint &bufferId, bufferPtr mappedPtr)
constexpr Optick::Category::Type Graphics
bool isMainThread() noexcept
Str StringFormat(const char *fmt, Args &&...args)
Handle console commands that start with a forward slash.
std::lock_guard< mutex > LockGuard
constexpr U16 to_U16(const T value)
constexpr gl46core::GLuint GL_NULL_HANDLE
Invalid object value. Used to compare handles and determine if they were properly created.
std::shared_lock< mutex > SharedLock
BufferUsageType _usageType
BufferParams _bufferParams
size_t _elementSize
Buffer primitive size in bytes.
BindResult bindActiveBuffer(gl46core::GLuint location, gl46core::GLuint bufferID, size_t offset, size_t stride)
Modify buffer bindings for the active vao.
vector< U16 > _smallIndicesTemp
std::pair< bufferPtr, size_t > _initialData
BufferBindConfig _bindConfig
BufferParams _bufferParams
glBufferImpl_uptr _buffer
SetBufferParams::BufferBindConfig _bindConfig
gl46core::GLsync _idxBufferSync