gl_engine: code refactoring

- clean up code
- resolve some data casting compiler warnings
This commit is contained in:
Hermet Park 2024-10-18 12:58:21 +09:00 committed by Hermet Park
parent 9109656800
commit b4304b6d1f
2 changed files with 195 additions and 282 deletions

View file

@ -53,20 +53,20 @@ struct GlBindingResource
* Can be a uniform location for a texture * Can be a uniform location for a texture
* Can be a uniform buffer binding index for a uniform block * Can be a uniform buffer binding index for a uniform block
*/ */
uint32_t bindPoint = {}; uint32_t bindPoint = 0;
uint32_t location = {}; GLint location = 0;
GLuint gBufferId = {}; GLuint gBufferId = 0;
uint32_t bufferOffset = {}; uint32_t bufferOffset = 0;
uint32_t bufferRange = {}; uint32_t bufferRange = 0;
GlBindingResource() = default; GlBindingResource() = default;
GlBindingResource(uint32_t index, uint32_t location, uint32_t bufferId, uint32_t offset, uint32_t range) GlBindingResource(uint32_t index, GLint location, GLuint bufferId, uint32_t offset, uint32_t range)
: type(GlBindingType::kUniformBuffer), bindPoint(index), location(location), gBufferId(bufferId), bufferOffset(offset), bufferRange(range) : type(GlBindingType::kUniformBuffer), bindPoint(index), location(location), gBufferId(bufferId), bufferOffset(offset), bufferRange(range)
{ {
} }
GlBindingResource(uint32_t bindPoint, uint32_t texId, uint32_t location) GlBindingResource(uint32_t bindPoint, GLuint texId, GLint location)
: type(GlBindingType::kTexture), bindPoint(bindPoint), location(location), gBufferId(texId) : type(GlBindingType::kTexture), bindPoint(bindPoint), location(location), gBufferId(texId)
{ {
} }

View file

@ -126,7 +126,7 @@ void GlRenderer::drawPrimitive(GlShape& sdata, uint8_t r, uint8_t g, uint8_t b,
bbox.intersect(vp); bbox.intersect(vp);
bool complexBlend = beginComplexBlending(bbox, sdata.geometry->getBounds()); auto complexBlend = beginComplexBlending(bbox, sdata.geometry->getBounds());
if (complexBlend) { if (complexBlend) {
vp = currentPass()->getViewport(); vp = currentPass()->getViewport();
@ -149,12 +149,7 @@ void GlRenderer::drawPrimitive(GlShape& sdata, uint8_t r, uint8_t g, uint8_t b,
return; return;
} }
task->setViewport(RenderRegion { task->setViewport({x, vp.h - y - h, w, h});
x,
vp.h - y - h,
w,
h
});
GlRenderTask* stencilTask = nullptr; GlRenderTask* stencilTask = nullptr;
@ -175,20 +170,15 @@ void GlRenderer::drawPrimitive(GlShape& sdata, uint8_t r, uint8_t g, uint8_t b,
} }
// matrix buffer // matrix buffer
{
const auto& matrix = sdata.geometry->getTransformMatrix(); const auto& matrix = sdata.geometry->getTransformMatrix();
float matrix44[16]; float matrix44[16];
currentPass()->getMatrix(matrix44, matrix); currentPass()->getMatrix(matrix44, matrix);
auto viewOffset = mGpuBuffer->push(matrix44, 16 * sizeof(float), true);
uint32_t loc = task->getProgram()->getUniformBlockIndex("Matrix");
uint32_t viewOffset = mGpuBuffer->push(matrix44, 16 * sizeof(float), true);
task->addBindResource(GlBindingResource{ task->addBindResource(GlBindingResource{
0, 0,
loc, task->getProgram()->getUniformBlockIndex("Matrix"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
viewOffset, viewOffset,
16 * sizeof(float), 16 * sizeof(float),
@ -197,38 +187,30 @@ void GlRenderer::drawPrimitive(GlShape& sdata, uint8_t r, uint8_t g, uint8_t b,
if (stencilTask) { if (stencilTask) {
stencilTask->addBindResource(GlBindingResource{ stencilTask->addBindResource(GlBindingResource{
0, 0,
static_cast<uint32_t>(stencilTask->getProgram()->getUniformBlockIndex("Matrix")), stencilTask->getProgram()->getUniformBlockIndex("Matrix"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
viewOffset, viewOffset,
16 * sizeof(float), 16 * sizeof(float),
}); });
} }
}
// color
{
float color[4] = {r / 255.f, g / 255.f, b / 255.f, a / 255.f};
uint32_t loc = task->getProgram()->getUniformBlockIndex("ColorInfo"); // color
float color[4] = {r / 255.f, g / 255.f, b / 255.f, a / 255.f};
task->addBindResource(GlBindingResource{ task->addBindResource(GlBindingResource{
1, 1,
loc, task->getProgram()->getUniformBlockIndex("ColorInfo"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
mGpuBuffer->push(color, 4 * sizeof(float), true), mGpuBuffer->push(color, 4 * sizeof(float), true),
4 * sizeof(float), 4 * sizeof(float),
}); });
}
if (stencilTask) { if (stencilTask) currentPass()->addRenderTask(new GlStencilCoverTask(stencilTask, task, stencilMode));
currentPass()->addRenderTask(new GlStencilCoverTask(stencilTask, task, stencilMode)); else currentPass()->addRenderTask(task);
} else {
currentPass()->addRenderTask(task);
}
if (complexBlend) { if (complexBlend) {
auto task = new GlRenderTask(mPrograms[RT_Stencil].get()); auto task = new GlRenderTask(mPrograms[RT_Stencil].get());
sdata.geometry->draw(task, mGpuBuffer.get(), flag); sdata.geometry->draw(task, mGpuBuffer.get(), flag);
endBlendingCompose(task, sdata.geometry->getTransformMatrix()); endBlendingCompose(task, sdata.geometry->getTransformMatrix());
} }
} }
@ -242,8 +224,7 @@ void GlRenderer::drawPrimitive(GlShape& sdata, const Fill* fill, RenderUpdateFla
bbox.intersect(vp); bbox.intersect(vp);
const Fill::ColorStop* stops = nullptr; const Fill::ColorStop* stops = nullptr;
auto stopCnt = min(fill->colorStops(&stops), auto stopCnt = min(fill->colorStops(&stops), static_cast<uint32_t>(MAX_GRADIENT_STOPS));
static_cast<uint32_t>(MAX_GRADIENT_STOPS));
if (stopCnt < 2) return; if (stopCnt < 2) return;
GlRenderTask* task = nullptr; GlRenderTask* task = nullptr;
@ -263,19 +244,14 @@ void GlRenderer::drawPrimitive(GlShape& sdata, const Fill* fill, RenderUpdateFla
return; return;
} }
bool complexBlend = beginComplexBlending(bbox, sdata.geometry->getBounds()); auto complexBlend = beginComplexBlending(bbox, sdata.geometry->getBounds());
if (complexBlend) vp = currentPass()->getViewport(); if (complexBlend) vp = currentPass()->getViewport();
auto x = bbox.x - vp.x; auto x = bbox.x - vp.x;
auto y = bbox.y - vp.y; auto y = bbox.y - vp.y;
task->setViewport(RenderRegion { task->setViewport({x, vp.h - y - bbox.h, bbox.w, bbox.h});
x,
vp.h - y - bbox.h,
bbox.w,
bbox.h
});
GlRenderTask* stencilTask = nullptr; GlRenderTask* stencilTask = nullptr;
GlStencilMode stencilMode = sdata.geometry->getStencilMode(flag); GlStencilMode stencilMode = sdata.geometry->getStencilMode(flag);
@ -285,9 +261,7 @@ void GlRenderer::drawPrimitive(GlShape& sdata, const Fill* fill, RenderUpdateFla
} }
// matrix buffer // matrix buffer
{
const auto& matrix = sdata.geometry->getTransformMatrix(); const auto& matrix = sdata.geometry->getTransformMatrix();
float invMat4[16]; float invMat4[16];
Matrix inv; Matrix inv;
inverse(&fill->transform(), &inv); inverse(&fill->transform(), &inv);
@ -296,12 +270,11 @@ void GlRenderer::drawPrimitive(GlShape& sdata, const Fill* fill, RenderUpdateFla
float matrix44[16]; float matrix44[16];
currentPass()->getMatrix(matrix44, matrix); currentPass()->getMatrix(matrix44, matrix);
uint32_t loc = task->getProgram()->getUniformBlockIndex("Matrix"); auto viewOffset = mGpuBuffer->push(matrix44, 16 * sizeof(float), true);
uint32_t viewOffset = mGpuBuffer->push(matrix44, 16 * sizeof(float), true);
task->addBindResource(GlBindingResource{ task->addBindResource(GlBindingResource{
0, 0,
loc, task->getProgram()->getUniformBlockIndex("Matrix"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
viewOffset, viewOffset,
16 * sizeof(float), 16 * sizeof(float),
@ -310,38 +283,35 @@ void GlRenderer::drawPrimitive(GlShape& sdata, const Fill* fill, RenderUpdateFla
if (stencilTask) { if (stencilTask) {
stencilTask->addBindResource(GlBindingResource{ stencilTask->addBindResource(GlBindingResource{
0, 0,
static_cast<uint32_t>(stencilTask->getProgram()->getUniformBlockIndex("Matrix")), stencilTask->getProgram()->getUniformBlockIndex("Matrix"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
viewOffset, viewOffset,
16 * sizeof(float), 16 * sizeof(float),
}); });
} }
loc = task->getProgram()->getUniformBlockIndex("InvMatrix");
viewOffset = mGpuBuffer->push(invMat4, 16 * sizeof(float), true); viewOffset = mGpuBuffer->push(invMat4, 16 * sizeof(float), true);
task->addBindResource(GlBindingResource{ task->addBindResource(GlBindingResource{
1, 1,
loc, task->getProgram()->getUniformBlockIndex("InvMatrix"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
viewOffset, viewOffset,
16 * sizeof(float), 16 * sizeof(float),
}); });
}
float alpha = 1.0f; auto alpha = 1.0f;
if (flag & RenderUpdateFlag::GradientStroke) { if (flag & RenderUpdateFlag::GradientStroke) {
float strokeWidth = sdata.rshape->strokeWidth(); auto strokeWidth = sdata.rshape->strokeWidth();
if (strokeWidth < MIN_GL_STROKE_WIDTH) { if (strokeWidth < MIN_GL_STROKE_WIDTH) {
alpha = strokeWidth / MIN_GL_STROKE_WIDTH; alpha = strokeWidth / MIN_GL_STROKE_WIDTH;
} }
} }
// gradient block // gradient block
{
GlBindingResource gradientBinding{}; GlBindingResource gradientBinding{};
uint32_t loc = task->getProgram()->getUniformBlockIndex("GradientInfo"); auto loc = task->getProgram()->getUniformBlockIndex("GradientInfo");
if (fill->type() == Type::LinearGradient) { if (fill->type() == Type::LinearGradient) {
auto linearFill = static_cast<const LinearGradient*>(fill); auto linearFill = static_cast<const LinearGradient*>(fill);
@ -416,7 +386,6 @@ void GlRenderer::drawPrimitive(GlShape& sdata, const Fill* fill, RenderUpdateFla
} }
task->addBindResource(gradientBinding); task->addBindResource(gradientBinding);
}
if (stencilTask) { if (stencilTask) {
currentPass()->addRenderTask(new GlStencilCoverTask(stencilTask, task, stencilMode)); currentPass()->addRenderTask(new GlStencilCoverTask(stencilTask, task, stencilMode));
@ -494,12 +463,7 @@ void GlRenderer::drawClip(Array<RenderData>& clips)
auto x = bbox.x - vp.x; auto x = bbox.x - vp.x;
auto y = bbox.y - vp.y; auto y = bbox.y - vp.y;
clipTask->setViewport(RenderRegion { clipTask->setViewport({x, vp.h - y - bbox.h, bbox.w, bbox.h});
x,
vp.h - y - bbox.h,
bbox.w,
bbox.h,
});
const auto& matrix = sdata->geometry->getTransformMatrix(); const auto& matrix = sdata->geometry->getTransformMatrix();
@ -507,9 +471,8 @@ void GlRenderer::drawClip(Array<RenderData>& clips)
currentPass()->getMatrix(matrix44, matrix); currentPass()->getMatrix(matrix44, matrix);
uint32_t loc = clipTask->getProgram()->getUniformBlockIndex("Matrix"); auto loc = clipTask->getProgram()->getUniformBlockIndex("Matrix");
auto viewOffset = mGpuBuffer->push(matrix44, 16 * sizeof(float), true);
uint32_t viewOffset = mGpuBuffer->push(matrix44, 16 * sizeof(float), true);
clipTask->addBindResource(GlBindingResource{ clipTask->addBindResource(GlBindingResource{
0, 0,
@ -532,7 +495,7 @@ void GlRenderer::drawClip(Array<RenderData>& clips)
}); });
maskTask->setDrawRange(identityIndexOffset, 6); maskTask->setDrawRange(identityIndexOffset, 6);
maskTask->setViewport(RenderRegion{0, 0, static_cast<int32_t>(vp.w), static_cast<int32_t>(vp.h)}); maskTask->setViewport({0, 0, static_cast<int32_t>(vp.w), static_cast<int32_t>(vp.h)});
currentPass()->addRenderTask(new GlClipTask(clipTask, maskTask)); currentPass()->addRenderTask(new GlClipTask(clipTask, maskTask));
} }
@ -585,26 +548,19 @@ void GlRenderer::endBlendingCompose(GlRenderTask* stencilTask, const Matrix& mat
auto w = vp.w; auto w = vp.w;
auto h = vp.h; auto h = vp.h;
stencilTask->setViewport(RenderRegion{ stencilTask->setViewport({x, passVp.h - y - h, w, h});
x,
passVp.h - y - h,
w,
h,
});
} }
stencilTask->setDrawDepth(currentPass()->nextDrawDepth()); stencilTask->setDrawDepth(currentPass()->nextDrawDepth());
{ {
// set view matrix // set view matrix
uint32_t loc = stencilTask->getProgram()->getUniformBlockIndex("Matrix");
float matrix44[16]; float matrix44[16];
currentPass()->getMatrix(matrix44, matrix); currentPass()->getMatrix(matrix44, matrix);
uint32_t viewOffset = mGpuBuffer->push(matrix44, 16 * sizeof(float), true); uint32_t viewOffset = mGpuBuffer->push(matrix44, 16 * sizeof(float), true);
stencilTask->addBindResource(GlBindingResource{ stencilTask->addBindResource(GlBindingResource{
0, 0,
loc, stencilTask->getProgram()->getUniformBlockIndex("Matrix"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
viewOffset, viewOffset,
16 * sizeof(float), 16 * sizeof(float),
@ -618,14 +574,8 @@ void GlRenderer::endBlendingCompose(GlRenderTask* stencilTask, const Matrix& mat
task->setDrawDepth(currentPass()->nextDrawDepth()); task->setDrawDepth(currentPass()->nextDrawDepth());
// src and dst texture // src and dst texture
{ task->addBindResource(GlBindingResource{1, blendPass.getFbo()->getColorTexture(), task->getProgram()->getUniformLocation("uSrcTexture")});
uint32_t loc = task->getProgram()->getUniformLocation("uSrcTexture"); task->addBindResource(GlBindingResource{2, dstCopyFbo->getColorTexture(), task->getProgram()->getUniformLocation("uDstTexture")});
task->addBindResource(GlBindingResource{1, blendPass.getFbo()->getColorTexture(), loc});
}
{
uint32_t loc = task->getProgram()->getUniformLocation("uDstTexture");
task->addBindResource(GlBindingResource{2, dstCopyFbo->getColorTexture(), loc});
}
currentPass()->addRenderTask(task); currentPass()->addRenderTask(task);
} }
@ -661,11 +611,7 @@ void GlRenderer::prepareBlitTask(GlBlitTask* task)
{ {
RenderRegion region{0, 0, static_cast<int32_t>(surface.w), static_cast<int32_t>(surface.h)}; RenderRegion region{0, 0, static_cast<int32_t>(surface.w), static_cast<int32_t>(surface.h)};
prepareCmpTask(task, region, surface.w, surface.h); prepareCmpTask(task, region, surface.w, surface.h);
task->addBindResource(GlBindingResource{0, task->getColorTexture(), task->getProgram()->getUniformLocation("uSrcTexture")});
{
uint32_t loc = task->getProgram()->getUniformLocation("uSrcTexture");
task->addBindResource(GlBindingResource{0, task->getColorTexture(), loc});
}
} }
@ -739,12 +685,7 @@ void GlRenderer::prepareCmpTask(GlRenderTask* task, const RenderRegion& vp, uint
task->setDrawRange(indexOffset, indices.count); task->setDrawRange(indexOffset, indices.count);
task->setViewport(RenderRegion{ task->setViewport({x, static_cast<int32_t>((passVp.h - y - h)), w, h});
x,
static_cast<int32_t>((passVp.h - y - h)),
w,
h,
});
} }
@ -810,8 +751,8 @@ void GlRenderer::endRenderPass(RenderCompositor* cmp)
prepareCmpTask(compose_task, gl_cmp->bbox, self_pass.getFboWidth(), self_pass.getFboHeight()); prepareCmpTask(compose_task, gl_cmp->bbox, self_pass.getFboWidth(), self_pass.getFboHeight());
compose_task->addBindResource(GlBindingResource{0, self_pass.getTextureId(), (uint)program->getUniformLocation("uSrcTexture")}); compose_task->addBindResource(GlBindingResource{0, self_pass.getTextureId(), program->getUniformLocation("uSrcTexture")});
compose_task->addBindResource(GlBindingResource{1, mask_pass.getTextureId(), (uint)program->getUniformLocation("uMaskTexture")}); compose_task->addBindResource(GlBindingResource{1, mask_pass.getTextureId(), program->getUniformLocation("uMaskTexture")});
compose_task->setDrawDepth(currentPass()->nextDrawDepth()); compose_task->setDrawDepth(currentPass()->nextDrawDepth());
compose_task->setParentSize(static_cast<uint32_t>(currentPass()->getViewport().w), static_cast<uint32_t>(currentPass()->getViewport().h)); compose_task->setParentSize(static_cast<uint32_t>(currentPass()->getViewport().w), static_cast<uint32_t>(currentPass()->getViewport().h));
@ -830,41 +771,29 @@ void GlRenderer::endRenderPass(RenderCompositor* cmp)
task->setDrawDepth(currentPass()->nextDrawDepth()); task->setDrawDepth(currentPass()->nextDrawDepth());
// matrix buffer // matrix buffer
{ float matrix[16] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
float matrix[16];
memset(matrix, 0, 16 * sizeof(float));
matrix[0] = 1.f;
matrix[5] = 1.f;
matrix[10] = 1.f;
matrix[15] = 1.f;
uint32_t loc = task->getProgram()->getUniformBlockIndex("Matrix");
task->addBindResource(GlBindingResource{ task->addBindResource(GlBindingResource{
0, 0,
loc, task->getProgram()->getUniformBlockIndex("Matrix"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
mGpuBuffer->push(matrix, 16 * sizeof(float), true), mGpuBuffer->push(matrix, 16 * sizeof(float), true),
16 * sizeof(float), 16 * sizeof(float),
}); });
}
// image info // image info
{
uint32_t info[4] = {(uint32_t)ColorSpace::ABGR8888, 0, cmp->opacity, 0}; uint32_t info[4] = {(uint32_t)ColorSpace::ABGR8888, 0, cmp->opacity, 0};
uint32_t loc = task->getProgram()->getUniformBlockIndex("ColorInfo");
task->addBindResource(GlBindingResource{ task->addBindResource(GlBindingResource{
1, 1,
loc, task->getProgram()->getUniformBlockIndex("ColorInfo"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
mGpuBuffer->push(info, 4 * sizeof(uint32_t), true), mGpuBuffer->push(info, 4 * sizeof(uint32_t), true),
4 * sizeof(uint32_t), 4 * sizeof(uint32_t),
}); });
}
// texture id // texture id
{ task->addBindResource(GlBindingResource{0, renderPass.getTextureId(), task->getProgram()->getUniformLocation("uTexture")});
uint32_t loc = task->getProgram()->getUniformLocation("uTexture");
task->addBindResource(GlBindingResource{0, renderPass.getTextureId(), loc});
}
task->setParentSize(static_cast<uint32_t>(currentPass()->getViewport().w), static_cast<uint32_t>(currentPass()->getViewport().h)); task->setParentSize(static_cast<uint32_t>(currentPass()->getViewport().w), static_cast<uint32_t>(currentPass()->getViewport().h));
currentPass()->addRenderTask(std::move(task)); currentPass()->addRenderTask(std::move(task));
} }
@ -897,7 +826,7 @@ bool GlRenderer::target(int32_t id, uint32_t w, uint32_t h)
mTargetFboId = static_cast<GLint>(id); mTargetFboId = static_cast<GLint>(id);
mRootTarget = make_unique<GlRenderTarget>(surface.w, surface.h); mRootTarget = make_unique<GlRenderTarget>(surface.w, surface.h);
mRootTarget->setViewport(RenderRegion{0, 0, static_cast<int32_t>(surface.w), static_cast<int32_t>(surface.h)}); mRootTarget->setViewport({0, 0, static_cast<int32_t>(surface.w), static_cast<int32_t>(surface.h)});
mRootTarget->init(mTargetFboId); mRootTarget->init(mTargetFboId);
mRenderPassStack.clear(); mRenderPassStack.clear();
@ -932,7 +861,7 @@ bool GlRenderer::sync()
prepareBlitTask(task); prepareBlitTask(task);
task->mClearBuffer = mClearBuffer; task->mClearBuffer = mClearBuffer;
task->setTargetViewport(RenderRegion{0, 0, static_cast<int32_t>(surface.w), static_cast<int32_t>(surface.h)}); task->setTargetViewport({0, 0, static_cast<int32_t>(surface.w), static_cast<int32_t>(surface.h)});
mGpuBuffer->flushToGPU(); mGpuBuffer->flushToGPU();
mGpuBuffer->bind(); mGpuBuffer->bind();
@ -955,7 +884,7 @@ bool GlRenderer::sync()
RenderRegion GlRenderer::region(RenderData data) RenderRegion GlRenderer::region(RenderData data)
{ {
if (currentPass()->isEmpty()) return RenderRegion{0, 0, 0, 0}; if (currentPass()->isEmpty()) return {0, 0, 0, 0};
auto shape = reinterpret_cast<GlShape*>(data); auto shape = reinterpret_cast<GlShape*>(data);
auto bounds = shape->geometry->getBounds(); auto bounds = shape->geometry->getBounds();
@ -1116,55 +1045,39 @@ bool GlRenderer::renderImage(void* data)
if (complexBlend) vp = currentPass()->getViewport(); if (complexBlend) vp = currentPass()->getViewport();
// matrix buffer // matrix buffer
{
const auto& matrix = sdata->geometry->getTransformMatrix(); const auto& matrix = sdata->geometry->getTransformMatrix();
float matrix44[16]; float matrix44[16];
currentPass()->getMatrix(matrix44, matrix); currentPass()->getMatrix(matrix44, matrix);
uint32_t loc = task->getProgram()->getUniformBlockIndex("Matrix");
task->addBindResource(GlBindingResource{ task->addBindResource(GlBindingResource{
0, 0,
loc, task->getProgram()->getUniformBlockIndex("Matrix"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
mGpuBuffer->push(matrix44, 16 * sizeof(float), true), mGpuBuffer->push(matrix44, 16 * sizeof(float), true),
16 * sizeof(float), 16 * sizeof(float),
}); });
}
// image info // image info
{
uint32_t info[4] = {(uint32_t)sdata->texColorSpace, sdata->texFlipY, sdata->opacity, 0}; uint32_t info[4] = {(uint32_t)sdata->texColorSpace, sdata->texFlipY, sdata->opacity, 0};
uint32_t loc = task->getProgram()->getUniformBlockIndex("ColorInfo");
task->addBindResource(GlBindingResource{ task->addBindResource(GlBindingResource{
1, 1,
loc, task->getProgram()->getUniformBlockIndex("ColorInfo"),
mGpuBuffer->getBufferId(), mGpuBuffer->getBufferId(),
mGpuBuffer->push(info, 4 * sizeof(uint32_t), true), mGpuBuffer->push(info, 4 * sizeof(uint32_t), true),
4 * sizeof(uint32_t), 4 * sizeof(uint32_t),
}); });
}
// texture id
{
uint32_t loc = task->getProgram()->getUniformLocation("uTexture");
task->addBindResource(GlBindingResource{0, sdata->texId, loc});
}
task->setViewport(RenderRegion{ // texture id
x, task->addBindResource(GlBindingResource{0, sdata->texId, task->getProgram()->getUniformLocation("uTexture")});
vp.h - y - bbox.h,
bbox.w, task->setViewport({x, vp.h - y - bbox.h, bbox.w, bbox.h});
bbox.h
});
currentPass()->addRenderTask(task); currentPass()->addRenderTask(task);
if (complexBlend) { if (complexBlend) {
auto task = new GlRenderTask(mPrograms[RT_Stencil].get()); auto task = new GlRenderTask(mPrograms[RT_Stencil].get());
sdata->geometry->draw(task, mGpuBuffer.get(), RenderUpdateFlag::Image); sdata->geometry->draw(task, mGpuBuffer.get(), RenderUpdateFlag::Image);
endBlendingCompose(task, sdata->geometry->getTransformMatrix()); endBlendingCompose(task, sdata->geometry->getTransformMatrix());
} }