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

Msaa on rt [DO NOT MERGE] #13856

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open

Msaa on rt [DO NOT MERGE] #13856

wants to merge 29 commits into from

Conversation

hana-alice
Copy link
Contributor

@hana-alice hana-alice commented Dec 20, 2022

add support for multipass msaa support. we have msaa but only works on single pass(otherwise GL rendering issues).

Changelog

  • fbo:
  • colorTextures:
    - colors0(set by user, replaced by msaa texture if msaaTex is set).
    - colors1(set by user, replaced by msaa texture if msaaTex is set).
    - ...
    - // resolve textures below appended in framegraph
    - depthStencilResolve(if msaa is set) // append in framegraph
    - color0resolve(if msaa is set) // append in framegraph
    - color1resolve(if msaa is set) // append in framegraph
    - ...
    - depthStencil(set by user)

now just create an additional msaa texture and implicilty replace the origin attachment slot in framegraph, and disable frabmebuffermsaa extension on windows.


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@github-actions
Copy link

github-actions bot commented Dec 20, 2022

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -55249,8 +55249,9 @@
             width: number;
             height: number;
             renderPassInfo: gfx.RenderPassInfo;
             swapchain?: gfx.Swapchain;
+            sampleCount?: gfx.SampleCount;
         }
         /**
          * @en The render window represents the render target, it could be an off screen frame buffer or the on screen buffer.
          * @zh 渲染窗口代表了一个渲染目标,可以是离屏的帧缓冲,也可以是屏幕缓冲
@@ -57675,8 +57676,9 @@
             name?: string;
             width: number;
             height: number;
             passInfo?: gfx.RenderPassInfo;
+            sampleCount?: gfx.SampleCount;
         }
         export interface _cocos_asset_asset_manager_cache__ICache<T> {
             add(key: string, val: T): T;
             get(key: string): T | undefined | null;
@@ -58988,8 +58990,12 @@
             glCurrentAttribLocs: boolean[];
             texUnitCacheMap: Record<string, number>;
             initialize(texUnit: number, bufferBindings: number, vertexAttributes: number): void;
         }
+        export interface _cocos_gfx_webgl2_webgl2_gpu_objects__IWebGL2ResolveTexture {
+            glTexture: WebGLTexture | null;
+            dirty: boolean;
+        }
         export interface _cocos_gfx_webgl2_webgl2_gpu_objects__IWebGL2GPUTexture {
             type: gfx.TextureType;
             format: gfx.Format;
             usage: gfx.TextureUsage;
@@ -59001,8 +59007,9 @@
             mipLevel: number;
             samples: gfx.SampleCount;
             flags: gfx.TextureFlags;
             isPowerOf2: boolean;
+            resolve: _cocos_gfx_webgl2_webgl2_gpu_objects__IWebGL2ResolveTexture;
             glTarget: GLenum;
             glInternalFmt: GLenum;
             glFormat: GLenum;
             glType: GLenum;

@hana-alice
Copy link
Contributor Author

@cocos-robot run test case

@hana-alice hana-alice closed this Dec 20, 2022
@hana-alice hana-alice reopened this Dec 20, 2022
@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS PASS PASS NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS FAIL NA align-mode,cameraUseRenderTex,layout-basic-grid,layout-basic-horizontal,layout-grid-contraint,layout-grid-expand,layout-scrollview,layout-size-changed,multi-canvas,object-group-image,priority,shield-node,terrain
Android_debug PASS PASS FAIL NA opacity

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS PASS PASS NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS FAIL advance-widget
Android_debug PASS PASS FAIL advance-widget

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
ios_release PASS PASS PASS NA
Mac_debug PASS PASS PASS NA
WebMobile_debug PASS PASS PASS NA

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
ios_release PASS PASS PASS NA
Mac_debug PASS PASS PASS NA
WebMobile_debug PASS PASS PASS NA

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS PASS PASS NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS FAIL advance-widget
Android_debug PASS PASS FAIL advance-widget

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

No task results found.

@hana-alice hana-alice requested a review from star-e December 22, 2022 03:37
#if CC_EDITOR
#if defined(CC_USE_GLES3) || defined(CC_USE_GLES2)
// by enabling this render target texture is mltisampled
static constexpr bool MSAA_RT{false};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we put them in namespace cc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, will add it in coming commit.

fbInfo.height = gpuFBO->gpuColorTextures.empty() ? dsWidth : std::min(fbInfo.height, dsHeight);
}

fbInfo.glFramebuffer = device->framebufferCacheMap()->getFramebufferByHash(gpuFBO);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will get by hash cause collision?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash by GLES2/3Texture, in gfx thread there is no GFXAgent or GFXValidator get involved, it's safe if there's no placement new on GFXTexture. To make it more reliable we can hash glTarget/glTexture/glRenderBuffer additionally.

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
ios_release PASS PASS PASS NA
Mac_debug PASS PASS PASS NA
WebMobile_debug PASS PASS PASS NA

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS PASS PASS NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS FAIL advance-widget
Android_debug PASS PASS FAIL advance-widget

@hana-alice
Copy link
Contributor Author

hana-alice commented Dec 22, 2022

for reference, msaa on web with 1(NoAA) / 2(PerformanceAA) / 4(BalanceAA) / 8(QualityAA) samples:
noaa
samples_2
samples_4
samples_8

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS PASS PASS NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS FAIL advance-widget
Android_debug PASS PASS FAIL advance-widget

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
ios_release PASS PASS PASS NA
Mac_debug PASS PASS PASS NA
WebMobile_debug PASS PASS PASS NA

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS PASS PASS NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS FAIL advance-widget
Android_debug PASS PASS FAIL advance-widget

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS PASS NA shadowCulling
WebMobile_release PASS PASS FAIL shadowCulling advance-widget,align-mode,bmfont,camera-layout,cameraUseRenderTex,capture_to_web,CoreJsTest,graphics-mask
Win32_release PASS PASS FAIL advance-widget
Android_debug PASS PASS FAIL advance-widget

@hana-alice
Copy link
Contributor Author

Known issue: if hdr is active, forwardstege use rgba16f as render texture, which is not copyable to swapchain (rgba8unorm) on android.
from es3.0 spec:

GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for the read buffer is greater than zero and the formats of draw and read buffers are not identical, or the source and destination rectangles are not defined with the same (X0, Y0) and (X1, Y1) bounds.

while this is not required on gl32, we are loading gl32 on windows:
image

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS PASS PASS NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS FAIL advance-widget
Android_debug PASS PASS FAIL advance-widget

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
ios_release PASS PASS PASS NA
Mac_debug PASS PASS PASS NA
WebMobile_debug PASS PASS PASS NA

@github-actions
Copy link

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS FAIL NA NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS FAIL advance-widget
Android_debug PASS PASS FAIL advance-widget

@github-actions
Copy link

github-actions bot commented Jan 3, 2023

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS FAIL NA NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS PASS NA
Android_debug PASS PASS PASS NA

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
ios_release PASS PASS PASS NA
Mac_debug PASS PASS PASS NA
WebMobile_debug PASS PASS PASS NA

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS FAIL NA NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS PASS NA
Android_debug PASS PASS PASS NA

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
ios_release PASS PASS PASS NA
Mac_debug PASS PASS PASS NA
WebMobile_debug PASS PASS PASS NA

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
ios_release PASS PASS PASS NA
Mac_debug PASS PASS PASS NA
WebMobile_debug PASS PASS PASS NA

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS FAIL NA NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS PASS NA
Android_debug PASS PASS PASS NA

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
ios_release PASS PASS PASS NA
Mac_debug PASS PASS PASS NA
WebMobile_debug PASS PASS PASS NA

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

@hana-alice, Please check the result of run test cases:

Task Details

Platform build runned result crashScene FailScene
WebDesktop_release PASS FAIL NA NA
WebMobile_release PASS PASS PASS NA
Win32_release PASS PASS FAIL NA render-ui-to-model
Android_debug PASS PASS PASS NA

@hana-alice hana-alice changed the base branch from v3.7.0 to develop January 6, 2023 01:54
@hana-alice
Copy link
Contributor Author

test-case: cocos/cocos-test-projects#746

when rendertexture samplecount is not SampleCount::ONE:
A default msaa texture will implicitly added in framegraph, writes to origin attachment will be redirect to msaa texture.

  • Due to lack of infomation of attachment load opaeration between current and next camera, we can't exactly known/figure out when is the right time to resolve, so everytime there is an attachment store action across different cameras(different passes), msaa texture will perform store too -- may be next camera performs a load action on what we render before.

  • Forward stage now is a fixed pipeline stage, resolve target is provide by default, so there is a MSAA resolve operation if origin attachment is not discard.

above only occurs in msaa camera.

@hana-alice hana-alice changed the title Msaa on rt Msaa on rt [DO NOT MERGE] May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants