Skip to content

Commit 89c7400

Browse files
committed
Bug fix: use integer typed formats for GL backend, e.g. GL_RED_INTEGER etc.
1 parent 675bc5b commit 89c7400

10 files changed

Lines changed: 193 additions & 126 deletions

File tree

include/LLGL/Format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ LLGL_EXPORT bool IsStencilFormat(const Format format);
515515
LLGL_EXPORT bool IsNormalizedFormat(const Format format);
516516

517517
/**
518-
\brief Returns true if the specified hardware format is an integral format (like Format::RGBA8UInt, Format::R8SInt etc.).
518+
\brief Returns true if the specified hardware format is an integral format (like Format::RGBA8UInt, Format::RGBA8UNorm, Format::R8SInt etc.).
519519
\remarks This also includes all normalized formats.
520520
\see IsNormalizedFormat
521521
\see Format

include/LLGL/PipelineLayoutFlags.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ struct BindingDescriptor
8282

8383
/**
8484
\brief Specifies to which kind of resource slot the resource will be bound. By default 0.
85-
\remarks When a Buffer is bound to a constant buffer slot for instance, the BindFlags::ConstantBuffer is requried.
86-
For texture resources, the bind flags are optional and only required to bind a read/write texture, e.g. \c image2D in GLSL or \c RWTexture2D in HLSL, using the BindFlags::Storage flag.
85+
\remarks When a Buffer is bound to a constant buffer slot for instance, the binding flag BindFlags::ConstantBuffer is required.
86+
When a Texture is bound to a sampled texture slot, the binding flag BindFlags::Sampled is required and so on.
8787
\see BindFlags
8888
*/
8989
long bindFlags = 0;

sources/Renderer/OpenGL/GLCore.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void GLThrowIfFailed(const GLenum status, const GLenum statusRequired, const cha
7373
}
7474
}
7575

76-
std::string GLDebugSourceToStr(const GLenum source)
76+
const char* GLDebugSourceToStr(const GLenum source)
7777
{
7878
#if defined LLGL_OPENGL && !defined __APPLE__
7979
switch (source)
@@ -89,7 +89,7 @@ std::string GLDebugSourceToStr(const GLenum source)
8989
return "";
9090
}
9191

92-
std::string GLDebugTypeToStr(const GLenum type)
92+
const char* GLDebugTypeToStr(const GLenum type)
9393
{
9494
#if defined LLGL_OPENGL && !defined __APPLE__
9595
switch (type)
@@ -108,7 +108,7 @@ std::string GLDebugTypeToStr(const GLenum type)
108108
return "";
109109
}
110110

111-
std::string GLDebugSeverityToStr(const GLenum severity)
111+
const char* GLDebugSeverityToStr(const GLenum severity)
112112
{
113113
#if defined LLGL_OPENGL && !defined __APPLE__
114114
switch (severity)
@@ -132,12 +132,10 @@ static bool GLParseInt(const GLubyte*& s, GLint& n)
132132
{
133133
if (*s >= '0' && *s <= '9')
134134
{
135-
n = 0;
136-
while (*s >= '0' && *s <= '9')
135+
for (n = 0; *s >= '0' && *s <= '9'; ++s)
137136
{
138137
n *= 10;
139138
n += (*s - '0');
140-
++s;
141139
}
142140
return true;
143141
}

sources/Renderer/OpenGL/GLCore.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ namespace LLGL
2121
void GLThrowIfFailed(const GLenum status, const GLenum statusRequired, const char* info = nullptr);
2222

2323
// Converts the GL debug source into a string.
24-
std::string GLDebugSourceToStr(const GLenum source);
24+
const char* GLDebugSourceToStr(const GLenum source);
2525

2626
// Converts the GL debug type into a string.
27-
std::string GLDebugTypeToStr(const GLenum type);
27+
const char* GLDebugTypeToStr(const GLenum type);
2828

2929
// Converts the GL debug severity into a string.
30-
std::string GLDebugSeverityToStr(const GLenum severity);
30+
const char* GLDebugSeverityToStr(const GLenum severity);
3131

3232
// Converts the boolean value into a GLboolean value.
3333
GLboolean GLBoolean(bool value);

sources/Renderer/OpenGL/GLTypes.cpp

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static GLenum MapImageFormat(const ImageFormat imageFormat)
290290
MapFailed("ImageFormat");
291291
}
292292

293-
/*static GLenum MapIntegerImageFormat(const ImageFormat imageFormat)
293+
static GLenum MapIntegerImageFormat(const ImageFormat imageFormat)
294294
{
295295
switch (imageFormat)
296296
{
@@ -314,20 +314,20 @@ static GLenum MapImageFormat(const ImageFormat imageFormat)
314314
default: break;
315315
}
316316
MapFailed("ImageFormat");
317-
}*/
317+
}
318318

319319
GLenum Map(const ImageFormat imageFormat)
320320
{
321321
return MapImageFormat(imageFormat);
322322
}
323323

324-
/*GLenum Map(const ImageFormat imageFormat, bool integerFormat)
324+
GLenum Map(const ImageFormat imageFormat, bool isIntegerType)
325325
{
326-
if (integerFormat)
326+
if (isIntegerType)
327327
return MapIntegerImageFormat(imageFormat);
328328
else
329329
return MapImageFormat(imageFormat);
330-
}*/
330+
}
331331

332332
GLenum Map(const CompareOp compareOp)
333333
{
@@ -980,6 +980,40 @@ DataType UnmapDataType(const GLenum type)
980980
UnmapFailed("DataType");
981981
}
982982

983+
bool IsIntegerTypedFormat(GLenum internalFormat)
984+
{
985+
switch (internalFormat)
986+
{
987+
case GL_R8UI:
988+
case GL_R8I:
989+
case GL_R16UI:
990+
case GL_R16I:
991+
case GL_R32I:
992+
case GL_R32UI:
993+
case GL_RG8UI:
994+
case GL_RG8I:
995+
case GL_RG16UI:
996+
case GL_RG16I:
997+
case GL_RG32UI:
998+
case GL_RG32I:
999+
case GL_RGB8UI:
1000+
case GL_RGB8I:
1001+
case GL_RGB16UI:
1002+
case GL_RGB16I:
1003+
case GL_RGB32UI:
1004+
case GL_RGB32I:
1005+
case GL_RGBA8UI:
1006+
case GL_RGBA8I:
1007+
case GL_RGBA16UI:
1008+
case GL_RGBA16I:
1009+
case GL_RGBA32UI:
1010+
case GL_RGBA32I:
1011+
return true;
1012+
default:
1013+
return false;
1014+
}
1015+
}
1016+
9831017

9841018
} // /namespace GLTypes
9851019

sources/Renderer/OpenGL/GLTypes.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ GLenum Map( const TextureType textureType );
3636
GLenum Map( const TextureSwizzle textureSwizzle );
3737
GLenum Map( const Format format );
3838
GLenum Map( const ImageFormat imageFormat );
39-
//GLenum Map( const ImageFormat imageFormat, bool integerFormat );
39+
GLenum Map( const ImageFormat imageFormat, bool isIntegerType );
4040
GLenum Map( const CompareOp compareOp );
4141
GLenum Map( const StencilOp stencilOp );
4242
GLenum Map( const BlendOp blendOp );
@@ -67,6 +67,9 @@ UniformType UnmapUniformType( const GLenum uniformType );
6767
Format UnmapFormat ( const GLenum internalFormat );
6868
DataType UnmapDataType ( const GLenum type );
6969

70+
// Returns true if the specified GL internal format has an integer type (e.g. GL_R32UI).
71+
bool IsIntegerTypedFormat(GLenum internalFormat);
72+
7073

7174
} // /namespace GLTypes
7275

sources/Renderer/OpenGL/RenderState/GLResourceHeap.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ static GLTexture* GetAsTextureView(const ResourceViewDescriptor& rvDesc)
139139
return nullptr;
140140
}
141141

142-
#if 0 //TODO
143-
static GLBuffer* GetAsBufferView(const ResourceViewDescriptor& rvDesc)
144-
{
145-
return nullptr;
146-
}
147-
#endif
148-
149142

150143
/*
151144
* GLResourceHeap class

0 commit comments

Comments
 (0)