diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-04-20 12:27:33 +0200 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-04-20 18:00:48 +0200 |
commit | 78609b36e0d61bd5535cfdc1ab2f1e0e59505042 (patch) | |
tree | ae7abfe545b95436204ac821a049ff4b80b81210 /external/libgltf | |
parent | adjust output file extension when exporting (bnc#870581) (diff) | |
download | core-78609b36e0d61bd5535cfdc1ab2f1e0e59505042.tar.gz core-78609b36e0d61bd5535cfdc1ab2f1e0e59505042.zip |
Patching libgltf: shader character buffers are used as c strings
Change-Id: Ic0c2bd47ffd5bf2d12e2201063ca688712a5f9b3
Diffstat (limited to 'external/libgltf')
-rw-r--r-- | external/libgltf/UnpackedTarball_libgltf.mk | 3 | ||||
-rw-r--r-- | external/libgltf/patches/json_charbuffer_used_as_cstring.patch (renamed from external/libgltf/patches/charbuffer_used_as_cstring.patch) | 0 | ||||
-rw-r--r-- | external/libgltf/patches/shader_charbuffer_used_as_cstring.patch | 94 |
3 files changed, 96 insertions, 1 deletions
diff --git a/external/libgltf/UnpackedTarball_libgltf.mk b/external/libgltf/UnpackedTarball_libgltf.mk index e83486d837b9..dd28b67422fc 100644 --- a/external/libgltf/UnpackedTarball_libgltf.mk +++ b/external/libgltf/UnpackedTarball_libgltf.mk @@ -24,7 +24,8 @@ $(eval $(call gb_UnpackedTarball_add_patches,libgltf,\ external/libgltf/patches/include_typo_texture.patch \ external/libgltf/patches/adress_of_temporary.patch \ external/libgltf/patches/avoid_c++11.patch \ - external/libgltf/patches/charbuffer_used_as_cstring.patch \ + external/libgltf/patches/json_charbuffer_used_as_cstring.patch \ + external/libgltf/patches/shader_charbuffer_used_as_cstring.patch \ )) # vim: set noet sw=4 ts=4: diff --git a/external/libgltf/patches/charbuffer_used_as_cstring.patch b/external/libgltf/patches/json_charbuffer_used_as_cstring.patch index 58f57017495a..58f57017495a 100644 --- a/external/libgltf/patches/charbuffer_used_as_cstring.patch +++ b/external/libgltf/patches/json_charbuffer_used_as_cstring.patch diff --git a/external/libgltf/patches/shader_charbuffer_used_as_cstring.patch b/external/libgltf/patches/shader_charbuffer_used_as_cstring.patch new file mode 100644 index 000000000000..000796c2f9f4 --- /dev/null +++ b/external/libgltf/patches/shader_charbuffer_used_as_cstring.patch @@ -0,0 +1,94 @@ +diff -ur libgltf.org/src/Common.cpp libgltf/src/Common.cpp +--- libgltf.org/src/Common.cpp 2014-04-20 10:46:20.065036606 +0200 ++++ libgltf/src/Common.cpp 2014-04-20 12:12:26.940821223 +0200 +@@ -521,8 +521,10 @@ + if(vShaderIdx >= 0 && fShaderIdx >= 0)
+ {
+ const char* pvShader = pGltfHandle->files[vShaderIdx]->buffer;
++ size_t ivShaderSize = pGltfHandle->files[vShaderIdx]->size;
+ const char* pfShader = pGltfHandle->files[fShaderIdx]->buffer;
+- mProgramId = mShaderProg.createProgram(pvShader, pfShader);
++ size_t ifShaderSize = pGltfHandle->files[fShaderIdx]->size;
++ mProgramId = mShaderProg.createProgram(pvShader, ivShaderSize, pfShader, ifShaderSize);
+ }
+ if (0 != mProgramId)
+ {
+diff -ur libgltf.org/src/Shaders.cpp libgltf/src/Shaders.cpp +--- libgltf.org/src/Shaders.cpp 2014-04-20 10:46:20.065036606 +0200 ++++ libgltf/src/Shaders.cpp 2014-04-20 12:15:42.683813064 +0200 +@@ -110,12 +110,12 @@ + return programId;
+ }
+
+-unsigned int ShaderProgram::createProgram(const char* pvShader, const char* pfShader)
++unsigned int ShaderProgram::createProgram(const char* pvShader, size_t ivShaderSize, const char* pfShader, size_t ifShaderSize)
+ {
+ unsigned int programId = glCreateProgram();
+- if (!loadShader(programId, pvShader, GL_VERTEX_SHADER))
++ if (!loadShader(programId, pvShader, ivShaderSize, GL_VERTEX_SHADER))
+ return 0;
+- if (!loadShader(programId, pfShader, GL_FRAGMENT_SHADER))
++ if (!loadShader(programId, pfShader, ifShaderSize, GL_FRAGMENT_SHADER))
+ return 0;
+
+ return programId;
+@@ -142,7 +142,7 @@ + return false;
+ }
+
+- if (!compileShader(shaderCode.c_str(), shaderId))
++ if (!compileShader(shaderCode.c_str(), shader.length(), shaderId))
+ {
+ std::cout << "compileShader : compileShader failed." << std::endl;
+ return false;
+@@ -158,11 +158,11 @@ + return true;
+ }
+
+-bool ShaderProgram::loadShader(unsigned int programId, const char* pShader, int type)
++bool ShaderProgram::loadShader(unsigned int programId, const char* pShader, size_t iSize, int type)
+ {
+ unsigned int shaderId = glCreateShader(type);
+
+- if (!compileShader(pShader, shaderId))
++ if (!compileShader(pShader, iSize, shaderId))
+ {
+ std::cout << "compileShader : compileShader failed." << std::endl;
+ return false;
+@@ -178,9 +178,10 @@ + return true;
+ }
+
+-bool ShaderProgram::compileShader(const char* pShader, unsigned int shaderId)
++bool ShaderProgram::compileShader(const char* pShader, size_t iSize, unsigned int shaderId)
+ {
+- glShaderSource(shaderId, 1, &pShader, NULL);
++ GLint iGLSize = iSize;
++ glShaderSource(shaderId, 1, &pShader, &iGLSize);
+ glCompileShader(shaderId);
+ int iStatus = 0;
+ glGetShaderiv(shaderId, GL_COMPILE_STATUS, &iStatus);
+diff -ur libgltf.org/src/Shaders.h libgltf/src/Shaders.h +--- libgltf.org/src/Shaders.h 2014-04-20 10:46:20.065036606 +0200 ++++ libgltf/src/Shaders.h 2014-04-20 12:11:36.816823313 +0200 +@@ -39,17 +39,17 @@ + void setUniform(unsigned int uProgId, const char* name, const glm::mat4 mMatrix);
+
+ unsigned int createProgram(const std::string& vName, const std::string& fName);
+- unsigned int createProgram(const char* pvShader, const char* pfShader);
++ unsigned int createProgram(const char* pvShader, size_t ivShaderSize, const char* pfShader, size_t ifShaderSize);
+
+ void deleteProgram(unsigned int programId);
+
+ void useProgram(unsigned int programId);
+
+ bool loadShader(unsigned int programId, const std::string& shaderName, int type);
+- bool loadShader(unsigned int programId, const char* pShader, int type);
++ bool loadShader(unsigned int programId, const char* pShader, size_t iSize, int type);
+ private:
+
+- bool compileShader(const char* pShader, unsigned int shaderId);
++ bool compileShader(const char* pShader, size_t iSize, unsigned int shaderId);
+
+ bool linkProgram(unsigned int programId, unsigned int shaderId);
+
|