From 6abffceb43f3a701697503cdd20a82dcea1e7b10 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Tue, 16 Oct 2018 09:39:32 +0200 Subject: [PATCH] Mip generation texture slot is higher and doesn't interfere anymore --- .../src/gpu/gl/GLBackendTexture.cpp | 9 +++++++-- libraries/gpu/src/gpu/Batch.cpp | 2 -- libraries/gpu/src/gpu/MipGeneration.slh | 20 +++++++++++++++++++ libraries/gpu/src/gpu/ShaderConstants.h | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 libraries/gpu/src/gpu/MipGeneration.slh diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendTexture.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendTexture.cpp index f4f2da3ee5..b74ff079d7 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendTexture.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendTexture.cpp @@ -86,9 +86,14 @@ void GLBackend::do_generateTextureMipsWithPipeline(const Batch& batch, size_t pa return; } - // Do not transfer the texture, this call is expected for rendering texture + // Always make sure the GLObject is in sync GLTexture* object = syncGPUObject(resourceTexture); - if (!object) { + if (object) { + GLuint to = object->_texture; + glActiveTexture(GL_TEXTURE0 + gpu::slot::texture::MipCreationInput); + glBindTexture(object->_target, to); + (void)CHECK_GL_ERROR(); + } else { return; } diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index 4cf678f26e..0e5fc1404f 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -418,8 +418,6 @@ void Batch::generateTextureMips(const TexturePointer& texture) { } void Batch::generateTextureMipsWithPipeline(const TexturePointer& texture, int numMips) { - setResourceTexture(gpu::slot::texture::MipCreationInput, texture); - ADD_COMMAND(generateTextureMipsWithPipeline); _params.emplace_back(_textures.cache(texture)); diff --git a/libraries/gpu/src/gpu/MipGeneration.slh b/libraries/gpu/src/gpu/MipGeneration.slh new file mode 100644 index 0000000000..bc8dd39042 --- /dev/null +++ b/libraries/gpu/src/gpu/MipGeneration.slh @@ -0,0 +1,20 @@ + +<@if not MIP_GENERATION_SLH@> +<@def MIP_GENERATION_SLH@> + +<@include gpu/ShaderConstants.h@> + +layout(binding=GPU_TEXTURE_MIP_CREATION_INPUT) uniform sampler2D texMap; + +in vec2 varTexCoord0; + +<@endif@> \ No newline at end of file diff --git a/libraries/gpu/src/gpu/ShaderConstants.h b/libraries/gpu/src/gpu/ShaderConstants.h index 426c64e913..0724b4eb40 100644 --- a/libraries/gpu/src/gpu/ShaderConstants.h +++ b/libraries/gpu/src/gpu/ShaderConstants.h @@ -22,7 +22,7 @@ #define GPU_TEXTURE_TRANSFORM_OBJECT 31 // Mip creation -#define GPU_TEXTURE_MIP_CREATION_INPUT 0 +#define GPU_TEXTURE_MIP_CREATION_INPUT 30 #define GPU_STORAGE_TRANSFORM_OBJECT 7