20#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
21#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
22#define GL_CALL_RET(RET, X) GR_GL_CALL_RET(GPUGL->glInterface(), RET, X)
33 std::string_view label)
34 :
GrSurface(gpu, dimensions, isProtected, label)
35 ,
GrRenderTarget(gpu, dimensions, sampleCount, isProtected, label,
std::move(stencil)) {
36 this->
init(format, ids);
37 this->setFlags(gpu->
glCaps(), ids);
47 std::string_view label)
48 :
GrSurface(gpu, dimensions, isProtected, label)
49 ,
GrRenderTarget(gpu, dimensions, sampleCount, isProtected, label) {
50 this->
init(format, ids);
51 this->setFlags(gpu->
glCaps(), ids);
54inline void GrGLRenderTarget::setFlags(
const GrGLCaps& glCaps,
const IDs& idDesc) {
55 if ((fMultisampleFBOID | fSingleSampleFBOID) == 0) {
71 switch (stencilBits) {
92 std::string_view label) {
117 bool useMultisampleFBO = (this->
numSamples() > 1);
119 fbi.
fFBOID = (useMultisampleFBO) ? fMultisampleFBOID : fSingleSampleFBOID;
137size_t GrGLRenderTarget::onGpuMemorySize()
const {
140 fTotalMemorySamplesPerPixel,
144void GrGLRenderTarget::onSetLabel() {
149bool GrGLRenderTarget::completeStencilAttachment(
GrAttachment* stencil,
bool useMultisampleFBO) {
152 fNeedsStencilAttachmentBind[useMultisampleFBO] =
true;
159 if (fMultisampleFBOID) {
168 if (internalSampleCount <= 1) {
175 fMultisampleFBOID = fSingleSampleFBOID;
179 GL_CALL(GenFramebuffers(1, &fMultisampleFBOID));
180 if (!fMultisampleFBOID) {
186 fDynamicMSAAAttachment.
reset(
188 this->dimensions(), this->backendFormat(), internalSampleCount,
190 if (!fDynamicMSAAAttachment) {
200 GrGLuint fboId = useMultisampleFBO ? fMultisampleFBOID : fSingleSampleFBOID;
203 if (fSingleSampleFBOID != 0 &&
204 fSingleSampleFBOID == fMultisampleFBOID &&
205 useMultisampleFBO != fDMSAARenderToTextureFBOIsMultisample) {
208 GL_CALL(FramebufferTexture2D(fboTarget,
214 if (useMultisampleFBO) {
218 GL_CALL(FramebufferTexture2DMultisample(fboTarget,
225 GL_CALL(FramebufferTexture2D(fboTarget,
231 fDMSAARenderToTextureFBOIsMultisample = useMultisampleFBO;
232 fNeedsStencilAttachmentBind[useMultisampleFBO] =
true;
237 if (fNeedsStencilAttachmentBind[useMultisampleFBO]) {
240 GL_CALL(FramebufferRenderbuffer(fboTarget,
245 GL_CALL(FramebufferRenderbuffer(fboTarget,
250 GL_CALL(FramebufferRenderbuffer(fboTarget,
256 GL_CALL(FramebufferRenderbuffer(fboTarget,
260 GL_CALL(FramebufferRenderbuffer(fboTarget,
266 if (!this->getGLGpu()->glCaps().skipErrorChecks() &&
267 !this->getGLGpu()->glCaps().rebindColorAttachmentAfterCheckFramebufferStatus()) {
269 GL_CALL_RET(status, CheckFramebufferStatus(fboTarget));
273 SkDebugf(
"WARNING: failed to attach stencil.\n");
277 fNeedsStencilAttachmentBind[useMultisampleFBO] =
false;
294 SkASSERT(this->getGLGpu()->glCaps().canResolveSingleToMSAA());
302 GrGLGpu* gpu = this->getGLGpu();
303 if (fSingleSampleFBOID) {
306 if (fMultisampleFBOID && fMultisampleFBOID != fSingleSampleFBOID) {
309 if (fMSColorRenderbufferID) {
310 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID));
313 fMultisampleFBOID = 0;
314 fSingleSampleFBOID = 0;
315 fMSColorRenderbufferID = 0;
320 fMultisampleFBOID = 0;
321 fSingleSampleFBOID = 0;
322 fMSColorRenderbufferID = 0;
326GrGLGpu* GrGLRenderTarget::getGLGpu()
const {
339 (this->
numSamples() == 1 && useMultisampleFBO);
346 bool refsWrappedRenderTargetObjects =
352 int numSamplesNotInTexture = fTotalMemorySamplesPerPixel;
354 --numSamplesNotInTexture;
356 if (numSamplesNotInTexture >= 1) {
359 numSamplesNotInTexture,
365 resourceName.
append(
"/renderbuffer");
370 renderbuffer_id.
appendU32(fMSColorRenderbufferID);
372 renderbuffer_id.
c_str());
int GrBackendFormatStencilBits(const GrBackendFormat &format)
#define GR_GL_DRAW_FRAMEBUFFER
#define GR_GL_READ_FRAMEBUFFER
#define GR_GL_RENDERBUFFER
#define GR_GL_STENCIL_ATTACHMENT
#define GR_GL_DEPTH_ATTACHMENT
#define GR_GL_FRAMEBUFFER_COMPLETE
#define GR_GL_FRAMEBUFFER
#define GR_GL_COLOR_ATTACHMENT0
GrGLFormat stencil_bits_to_format(int stencilBits)
#define GL_CALL_RET(RET, X)
static constexpr GrGLenum GrGLFormatToEnum(GrGLFormat format)
static constexpr bool GrGLFormatIsPackedDepthStencil(GrGLFormat format)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
bool msaaResolvesAutomatically() const
int internalMultisampleCount(const GrBackendFormat &format) const
GrResourceProvider * resourceProvider()
GrDirectContextPriv priv()
GrGLuint renderbufferID() const
static sk_sp< GrGLAttachment > MakeWrappedRenderBuffer(GrGpu *gpu, GrGLuint renderbufferID, SkISize dimensions, UsageFlags supportedUsages, int sampleCnt, GrGLFormat format)
GrGLFormat format() const
bool bindTexture0WhenChangingTextureFBOMultisampleCount() const
const GrGLCaps & glCaps() const
void bindFramebuffer(GrGLenum fboTarget, GrGLuint fboid)
void deleteFramebuffer(GrGLuint fboid)
bool canAttemptStencilAttachment(bool useMultisampleFBO) const override
void bindForResolve(ResolveDirection)
void onAbandon() override
GrGLRenderTarget(GrGLGpu *, const SkISize &, GrGLFormat, int sampleCount, const IDs &, skgpu::Protected, std::string_view label)
static sk_sp< GrGLRenderTarget > MakeWrapped(GrGLGpu *, const SkISize &, GrGLFormat, int sampleCount, const IDs &, int stencilBits, skgpu::Protected, std::string_view label)
void bindInternal(GrGLenum fboTarget, bool useMultisampleFBO)
GrBackendRenderTarget getBackendRenderTarget() const override
GrBackendFormat backendFormat() const override
GrGLFormat format() const
void init(GrGLFormat, const IDs &)
void dumpMemoryStatistics(SkTraceMemoryDump *traceMemoryDump) const override
bool ensureDynamicMSAAAttachment()
bool isMultisampledRenderToTexture() const
void onRelease() override
void dumpMemoryStatisticsPriv(SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
const GrDirectContext * getContext() const
bool wasDestroyed() const
SkString getResourceName() const
const GrCaps * caps() const
GrAttachment * getStencilAttachment() const
void onAbandon() override
void onRelease() override
int numStencilBits(bool useMSAASurface) const
sk_sp< GrAttachment > getDiscardableMSAAAttachment(SkISize dimensions, const GrBackendFormat &format, int sampleCnt, skgpu::Protected isProtected, GrMemoryless memoryless)
const GrCaps * caps() const
SkISize dimensions() const
static size_t ComputeSize(const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
virtual GrTexture * asTexture()
void append(const char text[])
void appendU32(uint32_t value)
const char * c_str() const
virtual void setMemoryBacking(const char *dumpName, const char *backingType, const char *backingObjectId)=0
virtual bool shouldDumpWrappedObjects() const
void reset(T *ptr=nullptr)
FlPixelBufferTexturePrivate * priv
uint32_t uint32_t * format
SK_API GrBackendRenderTarget MakeGL(int width, int height, int sampleCnt, int stencilBits, const GrGLFramebufferInfo &glInfo)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
skgpu::Protected fProtected
int fTotalMemorySamplesPerPixel
GrGLuint fMultisampleFBOID
GrBackendObjectOwnership fRTFBOOwnership
GrGLuint fSingleSampleFBOID
GrGLuint fMSColorRenderbufferID