1
0
forked from 0ad/0ad

Fix GLES 2.0 build after the compute shader addition

This commit is contained in:
Stan 2024-09-12 17:31:43 +03:00
parent 26994b156b
commit de9dab27ab
Signed by: Stan
GPG Key ID: 244943DFF8370D60
3 changed files with 18 additions and 1 deletions

View File

@ -43,7 +43,7 @@ extern void* wutil_GetAppHDC();
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#if !CONFIG2_GLES && (defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND))
#if !OS_MACOSX && !OS_MAC && !CONFIG2_GLES && (defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND))
#if defined(SDL_VIDEO_DRIVER_X11)
#include <glad/glx.h>

View File

@ -1257,11 +1257,17 @@ void CDeviceCommandContext::Dispatch(
const uint32_t groupCountY,
const uint32_t groupCountZ)
{
#if !CONFIG2_GLES
ENSURE(m_InsideComputePass);
glDispatchCompute(groupCountX, groupCountY, groupCountZ);
// TODO: we might want to do binding tracking to avoid redundant barriers.
glMemoryBarrier(
GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL_TEXTURE_FETCH_BARRIER_BIT | GL_TEXTURE_UPDATE_BARRIER_BIT | GL_FRAMEBUFFER_BARRIER_BIT);
#else
UNUSED2(groupCountX);
UNUSED2(groupCountY);
UNUSED2(groupCountZ);
#endif
}
void CDeviceCommandContext::SetTexture(const int32_t bindingSlot, ITexture* texture)
@ -1316,9 +1322,13 @@ void CDeviceCommandContext::SetStorageTexture(const int32_t bindingSlot, ITextur
m_ShaderProgram->GetTextureUnit(bindingSlot);
if (!textureUnit.type)
return;
#if !CONFIG2_GLES
ENSURE(textureUnit.type == GL_IMAGE_2D);
#endif
ENSURE(texture->GetFormat() == Format::R8G8B8A8_UNORM);
#if !CONFIG2_GLES
glBindImageTexture(textureUnit.unit, texture->As<CTexture>()->GetHandle(), 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
#endif
}
void CDeviceCommandContext::SetUniform(

View File

@ -675,9 +675,11 @@ public:
case GL_FRAGMENT_SHADER:
stageDefine = "STAGE_FRAGMENT";
break;
#if !CONFIG2_GLES
case GL_COMPUTE_SHADER:
stageDefine = "STAGE_COMPUTE";
break;
#endif
default:
break;
}
@ -1341,6 +1343,7 @@ std::unique_ptr<CShaderProgram> CShaderProgram::Create(CDevice* device, const CS
if (isGLSL)
{
#if !CONFIG2_GLES
if (!computeFile.empty())
{
ENSURE(streamFlags == 0);
@ -1349,6 +1352,10 @@ std::unique_ptr<CShaderProgram> CShaderProgram::Create(CDevice* device, const CS
const PS::StaticVector<std::tuple<VfsPath, GLenum>, 2> shaderStages{computeFile.empty()
? PS::StaticVector<std::tuple<VfsPath, GLenum>, 2>{{vertexFile, GL_VERTEX_SHADER}, {fragmentFile, GL_FRAGMENT_SHADER}}
: PS::StaticVector<std::tuple<VfsPath, GLenum>, 2>{{computeFile, GL_COMPUTE_SHADER}}};
#else
const PS::StaticVector<std::tuple<VfsPath, GLenum>, 2> shaderStages{PS::StaticVector<std::tuple<VfsPath, GLenum>, 2>{{vertexFile, GL_VERTEX_SHADER}, {fragmentFile, GL_FRAGMENT_SHADER}}};
#endif
return std::make_unique<CShaderProgramGLSL>(
device, name, xmlFilename, shaderStages, defines,
vertexAttribs, streamFlags);