MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / EnableTextureArrays

Method EnableTextureArrays

GTE/Graphics/GL46/GL46Engine.cpp:664–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

662}
663
664void GL46Engine::EnableTextureArrays(Shader const* shader, GLuint program)
665{
666 int32_t const index = TextureArray::shaderDataLookup;
667 for (auto const& ta : shader->GetData(index))
668 {
669 if (!ta.object)
670 {
671 LogError(ta.name + " is null texture array.");
672 }
673
674 auto texture = static_cast<GL46TextureArray*>(Bind(ta.object));
675 if (!texture)
676 {
677 LogError("Failed to bind texture array.");
678 }
679
680 // By convension, ta.isGpuWritable is true for "image*" and false
681 // for "sampler*".
682 GLuint handle = texture->GetGLHandle();
683 if (ta.isGpuWritable)
684 {
685 // For "image*" objects in the shader, use "readonly" or
686 // "writeonly" attributes in the layout to control R/W/RW access
687 // using shader compiler and then connect as GL_READ_WRITE here.
688 // Always bind level 0 and all layers.
689 GLint unit = mTextureImageUnitMap.AcquireUnit(program, ta.bindPoint);
690 glUniform1i(ta.bindPoint, unit);
691 uint32_t format = texture->GetTexture()->GetFormat();
692 GLuint internalFormat = texture->GetInternalFormat(format);
693 glBindImageTexture(unit, handle, 0, GL_TRUE, 0, GL_READ_WRITE, internalFormat);
694 }
695 else
696 {
697 GLint unit = mTextureSamplerUnitMap.AcquireUnit(program, ta.bindPoint);
698 glUniform1i(ta.bindPoint, unit);
699 glActiveTexture(GL_TEXTURE0 + unit);
700 glBindTexture(texture->GetTarget(), handle);
701 }
702 }
703}
704
705void GL46Engine::DisableTextureArrays(Shader const* shader, GLuint program)
706{

Callers

nothing calls this directly

Calls 11

glUniform1iFunction · 0.85
glBindImageTextureFunction · 0.85
glActiveTextureFunction · 0.85
glBindTextureFunction · 0.85
GetGLHandleMethod · 0.80
AcquireUnitMethod · 0.80
GetInternalFormatMethod · 0.80
GetTargetMethod · 0.80
GetDataMethod · 0.45
GetFormatMethod · 0.45
GetTextureMethod · 0.45

Tested by

no test coverage detected