mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-13 14:48:32 +09:00
[Feat] (MG_Backend/DirectGLES): support compute shaders
This commit is contained in:
@@ -97,6 +97,11 @@ namespace MobileGL::MG_State::GLState {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto& imageBinding : m_imageTextureBindings) {
|
||||
if (imageBinding.Texture == it->second) {
|
||||
imageBinding.Bind(nullptr, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8);
|
||||
}
|
||||
}
|
||||
m_textureObjects.erase(it);
|
||||
}
|
||||
m_indexGenerator.Delete(index);
|
||||
@@ -109,6 +114,18 @@ namespace MobileGL::MG_State::GLState {
|
||||
return m_textureUnits[unit];
|
||||
}
|
||||
|
||||
ImageTextureBinding& TextureState::GetImageTextureBinding(Int unit) {
|
||||
MOBILEGL_ASSERT(unit >= 0 && unit < MAX_TEXTURE_IMAGE_UNITS, "Image unit is out of range: %d > %d", unit,
|
||||
MAX_TEXTURE_IMAGE_UNITS - 1);
|
||||
return m_imageTextureBindings[unit];
|
||||
}
|
||||
|
||||
const ImageTextureBinding& TextureState::GetImageTextureBinding(Int unit) const {
|
||||
MOBILEGL_ASSERT(unit >= 0 && unit < MAX_TEXTURE_IMAGE_UNITS, "Image unit is out of range: %d > %d", unit,
|
||||
MAX_TEXTURE_IMAGE_UNITS - 1);
|
||||
return m_imageTextureBindings[unit];
|
||||
}
|
||||
|
||||
Int TextureState::GetActiveTextureUnit() const {
|
||||
return m_activeTextureUnit;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,27 @@
|
||||
#include "TextureUnit.h"
|
||||
|
||||
namespace MobileGL::MG_State::GLState {
|
||||
struct ImageTextureBinding {
|
||||
SharedPtr<ITextureObject> Texture;
|
||||
GLint Level = 0;
|
||||
GLboolean Layered = GL_FALSE;
|
||||
GLint Layer = 0;
|
||||
GLenum Access = GL_READ_ONLY;
|
||||
GLenum Format = GL_RGBA8;
|
||||
Uint16 Version = 0;
|
||||
|
||||
void Bind(SharedPtr<ITextureObject> texture, GLint level, GLboolean layered, GLint layer, GLenum access,
|
||||
GLenum format) {
|
||||
Texture = Move(texture);
|
||||
Level = level;
|
||||
Layered = layered;
|
||||
Layer = layer;
|
||||
Access = access;
|
||||
Format = format;
|
||||
++Version;
|
||||
}
|
||||
};
|
||||
|
||||
class TextureState {
|
||||
public:
|
||||
static constexpr int MAX_TEXTURE_IMAGE_UNITS = 32;
|
||||
@@ -23,6 +44,8 @@ namespace MobileGL::MG_State::GLState {
|
||||
const SharedPtr<ITextureObject>& CreateTextureObject(Uint index, TextureTarget target);
|
||||
const SharedPtr<ITextureObject>& GetTextureObject(Uint index);
|
||||
TextureUnit& GetUnitObject(Int unit);
|
||||
ImageTextureBinding& GetImageTextureBinding(Int unit);
|
||||
const ImageTextureBinding& GetImageTextureBinding(Int unit) const;
|
||||
Int GetActiveTextureUnit() const;
|
||||
void SetActiveTextureUnit(Int unit);
|
||||
void MarkTextureObjectForDeletion(Uint index);
|
||||
@@ -32,6 +55,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
private:
|
||||
Int m_activeTextureUnit = 0;
|
||||
Array<TextureUnit, MAX_TEXTURE_IMAGE_UNITS> m_textureUnits;
|
||||
Array<ImageTextureBinding, MAX_TEXTURE_IMAGE_UNITS> m_imageTextureBindings;
|
||||
IndexGenerator<Uint> m_indexGenerator;
|
||||
UnorderedMap<GLuint, SharedPtr<ITextureObject>> m_textureObjects;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user