Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase dirtyId when Framebuffer.multisample is changed #9390

Open
wants to merge 1 commit into
base: fix/msaaSamples
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 34 additions & 17 deletions packages/core/src/framebuffer/Framebuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,7 @@ export class Framebuffer
/** Height of framebuffer in pixels. */
public height: number;

/**
* Desired number of samples for antialiasing. 0 means AA should not be used.
*
* Experimental WebGL2 feature, allows to use antialiasing in individual renderTextures.
* Antialiasing is the same as for main buffer with renderer `antialias: true` options.
* Seriously affects GPU memory consumption and GPU performance.
* @example
* import { MSAA_QUALITY } from 'pixi.js';
*
* renderTexture.framebuffer.multisample = MSAA_QUALITY.HIGH;
* // ...
* renderer.render(myContainer, { renderTexture });
* renderer.framebuffer.blit(); // Copies data from MSAA framebuffer to texture
* @default PIXI.MSAA_QUALITY.NONE
*/
public multisample: MSAA_QUALITY;
protected _multisample: MSAA_QUALITY;

stencil: boolean;
depth: boolean;
Expand Down Expand Up @@ -69,7 +54,7 @@ export class Framebuffer
this.glFramebuffers = {};

this.disposeRunner = new Runner('disposeFramebuffer');
this.multisample = MSAA_QUALITY.NONE;
this._multisample = MSAA_QUALITY.NONE;
}

/**
Expand All @@ -81,6 +66,38 @@ export class Framebuffer
return this.colorTextures[0];
}

/**
* Desired number of samples for antialiasing. 0 means AA should not be used.
*
* Allows to use antialiasing in individual renderTextures (WebGL2 only).
* Antialiasing is the same as for main buffer with renderer `antialias: true` options.
* Seriously affects GPU memory consumption and GPU performance.
* @example
* import { MSAA_QUALITY } from 'pixi.js';
*
* renderTexture.framebuffer.multisample = MSAA_QUALITY.HIGH;
* // ...
* renderer.render(myContainer, { renderTexture });
* renderer.framebuffer.blit(); // Copies data from MSAA framebuffer to texture
* @default PIXI.MSAA_QUALITY.NONE
*/
get multisample(): MSAA_QUALITY
{
return this._multisample;
}

set multisample(value: MSAA_QUALITY)
{
if (this._multisample === value)
{
return;
}

this._multisample = value;
this.dirtyId++;
this.dirtyFormat++;
}

/**
* Add texture to the colorTexture array.
* @param index - Index of the array to add the texture to
Expand Down