| 662 | } |
| 663 | |
| 664 | void 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 | |
| 705 | void GL46Engine::DisableTextureArrays(Shader const* shader, GLuint program) |
| 706 | { |
nothing calls this directly
no test coverage detected