Explorar o código

Bugfix: Properly bind all slices of a 3D texture when performing image read/write in OpenGL, as suggested by @w-flo

BearishSun %!s(int64=8) %!d(string=hai) anos
pai
achega
92155445c4
Modificáronse 1 ficheiros con 20 adicións e 1 borrados
  1. 20 1
      Source/BansheeGLRenderAPI/BsGLRenderAPI.cpp

+ 20 - 1
Source/BansheeGLRenderAPI/BsGLRenderAPI.cpp

@@ -722,11 +722,30 @@ namespace bs { namespace ct
 						if (texture != nullptr)
 						{
 							GLTexture* tex = static_cast<GLTexture*>(texture.get());
+							auto& texProps = tex->getProperties();
+
+							GLboolean bindAllLayers = 
+								texProps.getNumFaces() == surface.numFaces ||
+								surface.numFaces == 0;
+
+							if(!bindAllLayers && surface.numFaces > 1)
+							{
+								LOGWRN("Attempting to bind multiple faces of a load-store texture. You are allowed to bind \
+									either a single face, or all the faces of the texture. Only the first face will \
+									be bound instead.");
+							}
+
+							if(surface.numMipLevels > 1)
+							{
+								LOGWRN("Attempting to bind multiple mip levels of a load-store texture. This is not \
+									supported and only the first provided level will be bound.");
+							}
+
 							glBindImageTexture(
 								unit,
 								tex->getGLID(),
 								surface.mipLevel,
-								surface.numFaces > 1,
+								bindAllLayers,
 								surface.face,
 								GL_READ_WRITE,
 								tex->getGLFormat());