<commit_before>#include "buffer.hpp"
#include "utils/flagoperators.hpp"

namespace gl
{
	Buffer::BufferBinding Buffer::s_boundVertexBuffers[s_numVertexBufferBindings];
	Buffer::BufferBinding Buffer::s_boundUBOs[s_numUBOBindings];
	Buffer::BufferBinding Buffer::s_boundSSBOs[s_numSSBOBindings];
	BufferId Buffer::s_boundIndexBuffer = 0;
	BufferId Buffer::s_boundIndirectDrawBuffer = 0;
	BufferId Buffer::s_boundIndirectDispatchBuffer = 0;

	Buffer::Buffer(GLsizeiptr _sizeInBytes, UsageFlag _usageFlags, const void* _data) :
        m_sizeInBytes(_sizeInBytes),
		m_usageFlags(_usageFlags),

		m_mappedDataOffset(0),
		m_mappedDataSize(0),
		m_mappedData(nullptr)
    {
		GLHELPER_ASSERT(static_cast<uint32_t>(m_usageFlags & UsageFlag::EXPLICIT_FLUSH) == 0 || static_cast<uint32_t>(m_usageFlags & UsageFlag::MAP_PERSISTENT) > 0,
			   "EXPLICIT_FLUSH only valid in combination with PERSISTENT");
		GLHELPER_ASSERT(static_cast<uint32_t>(m_usageFlags & UsageFlag::MAP_COHERENT) == 0 || static_cast<uint32_t>(m_usageFlags & UsageFlag::MAP_PERSISTENT) > 0,
			   "MAP_COHERENT only valid in combination with PERSISTENT");

		GL_CALL(glCreateBuffers, 1, &m_bufferObject);
		GL_CALL(glNamedBufferStorage, m_bufferObject, _sizeInBytes, _data, static_cast<GLbitfield>(_usageFlags));


		// Persistent buffers do not need to be unmapped!
		if (any(m_usageFlags & UsageFlag::MAP_PERSISTENT))
		{
			MapWriteFlag mapWriteFlags = any(m_usageFlags & UsageFlag::EXPLICIT_FLUSH) ? MapWriteFlag::FLUSH_EXPLICIT : MapWriteFlag::NONE;

			if (any(m_usageFlags & UsageFlag::MAP_WRITE))
				Map(MapType::WRITE, mapWriteFlags);<commit_msg>fixed: FLUSH_EXPLICIT flag is invalid for BufferStorage (use flag only in map())<commit_after>#include "buffer.hpp"
#include "utils/flagoperators.hpp"

namespace gl
{
	Buffer::BufferBinding Buffer::s_boundVertexBuffers[s_numVertexBufferBindings];
	Buffer::BufferBinding Buffer::s_boundUBOs[s_numUBOBindings];
	Buffer::BufferBinding Buffer::s_boundSSBOs[s_numSSBOBindings];
	BufferId Buffer::s_boundIndexBuffer = 0;
	BufferId Buffer::s_boundIndirectDrawBuffer = 0;
	BufferId Buffer::s_boundIndirectDispatchBuffer = 0;

	Buffer::Buffer(GLsizeiptr _sizeInBytes, UsageFlag _usageFlags, const void* _data) :
        m_sizeInBytes(_sizeInBytes),
		m_usageFlags(_usageFlags & ~EXPLICIT_FLUSH),

		m_mappedDataOffset(0),
		m_mappedDataSize(0),
		m_mappedData(nullptr)
    {
		GLHELPER_ASSERT(static_cast<uint32_t>(m_usageFlags & UsageFlag::MAP_COHERENT) == 0 || static_cast<uint32_t>(m_usageFlags & UsageFlag::MAP_PERSISTENT) > 0,
			   "MAP_COHERENT only valid in combination with PERSISTENT");

		GL_CALL(glCreateBuffers, 1, &m_bufferObject);
		GL_CALL(glNamedBufferStorage, m_bufferObject, _sizeInBytes, _data, static_cast<GLbitfield>(m_usageFlags));


		// Persistent buffers do not need to be unmapped!
		if (any(m_usageFlags & UsageFlag::MAP_PERSISTENT))
		{
			MapWriteFlag mapWriteFlags = any(_usageFlags & UsageFlag::EXPLICIT_FLUSH) ? MapWriteFlag::FLUSH_EXPLICIT : MapWriteFlag::NONE;

			if (any(m_usageFlags & UsageFlag::MAP_WRITE))
				Map(MapType::WRITE, mapWriteFlags);
{'fraction_non_alphanumeric': 0.10604591011962496, 'fraction_numerical': 0.009699321047526674, 'mean_word_length': 7.54696132596685, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4076654', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1084, 'n_words': 176}