mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Feat] (MG_Impl/Texture): Implement PBO.
This commit is contained in:
@@ -66,8 +66,20 @@ namespace MobileGL {
|
|||||||
SizeT imageSize = 0;
|
SizeT imageSize = 0;
|
||||||
const SizeT bytesPerPixel = MG_Util::GetInputBytesPerPixel(textureInternalFormat, texturePixelDataType);
|
const SizeT bytesPerPixel = MG_Util::GetInputBytesPerPixel(textureInternalFormat, texturePixelDataType);
|
||||||
|
|
||||||
|
const void* originalPixels = pixels;
|
||||||
|
|
||||||
|
// PBO
|
||||||
|
const auto& pixelUnpackBufferObject =
|
||||||
|
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::PixelUnpack).GetBoundObject();
|
||||||
|
if (pixelUnpackBufferObject) {
|
||||||
|
MGLOG_D("TexSubImage2D_State: Using Pixel Unpack Buffer Object ID: %u",
|
||||||
|
pixelUnpackBufferObject->GetExternalIndex());
|
||||||
|
originalPixels = reinterpret_cast<const char*>(pixelUnpackBufferObject->GetDataReadOnly()->data()) +
|
||||||
|
reinterpret_cast<SizeT>(pixels);
|
||||||
|
}
|
||||||
|
|
||||||
void* processedPixels = MG_Util::PixelStoreProcessor::ProcessTexturePixelsDataUnpack(
|
void* processedPixels = MG_Util::PixelStoreProcessor::ProcessTexturePixelsDataUnpack(
|
||||||
pixels, MG_State::pGLContext->GetPixelStoreParameters(true), bytesPerPixel, {width, height, 1},
|
originalPixels, MG_State::pGLContext->GetPixelStoreParameters(true), bytesPerPixel, {width, height, 1},
|
||||||
false /*TODO*/, imageSize);
|
false /*TODO*/, imageSize);
|
||||||
|
|
||||||
if (!processedPixels || imageSize == 0) {
|
if (!processedPixels || imageSize == 0) {
|
||||||
@@ -360,10 +372,22 @@ namespace MobileGL {
|
|||||||
const SizeT bytesPerPixel = MG_Util::GetInputBytesPerPixel(textureInternalFormat, texturePixelDataType);
|
const SizeT bytesPerPixel = MG_Util::GetInputBytesPerPixel(textureInternalFormat, texturePixelDataType);
|
||||||
const SizeT totalBytes = width * height * bytesPerPixel;
|
const SizeT totalBytes = width * height * bytesPerPixel;
|
||||||
|
|
||||||
if (pixels) {
|
const void* originalPixels = pixels;
|
||||||
|
|
||||||
|
// PBO
|
||||||
|
const auto& pixelUnpackBufferObject =
|
||||||
|
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::PixelUnpack).GetBoundObject();
|
||||||
|
if (pixelUnpackBufferObject) {
|
||||||
|
MGLOG_D("TexImage2D_State: Using Pixel Unpack Buffer Object ID: %u",
|
||||||
|
pixelUnpackBufferObject->GetExternalIndex());
|
||||||
|
originalPixels = reinterpret_cast<const char*>(pixelUnpackBufferObject->GetDataReadOnly()->data()) +
|
||||||
|
reinterpret_cast<SizeT>(pixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (originalPixels) {
|
||||||
processedPixels = MG_Util::PixelStoreProcessor::ProcessTexturePixelsDataUnpack(
|
processedPixels = MG_Util::PixelStoreProcessor::ProcessTexturePixelsDataUnpack(
|
||||||
pixels, MG_State::pGLContext->GetPixelStoreParameters(true), bytesPerPixel, {width, height, 1},
|
originalPixels, MG_State::pGLContext->GetPixelStoreParameters(true), bytesPerPixel,
|
||||||
false, imageSize);
|
{width, height, 1}, false, imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
MG_State::GLState::MipmapLevelInput mipmap =
|
MG_State::GLState::MipmapLevelInput mipmap =
|
||||||
@@ -831,6 +855,7 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BindTexture_State(GLenum target, GLuint texture) {
|
void BindTexture_State(GLenum target, GLuint texture) {
|
||||||
|
MGLOG_D("BindTexture_State called with target: 0x%X, texture: %u", target, texture);
|
||||||
// ======================= Converting ================================
|
// ======================= Converting ================================
|
||||||
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
|
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user