-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SGSR stands for Snapdragon Game Super Resolution. It is an efficient upscaler for mobile. Split the upscaling passes into multiple methods in PostProcessManager. Also, add a way to preserve the alpha channel in the FXAA pass.
- Loading branch information
1 parent
5b3343f
commit 48a2c64
Showing
10 changed files
with
458 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
|
||
SPDX-License-Identifier: BSD-3-Clause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
material { | ||
name : sgsr1, | ||
parameters : [ | ||
{ | ||
type : sampler2d, | ||
name : color, | ||
precision: medium | ||
}, | ||
{ | ||
type : float4, | ||
name : viewport, | ||
precision: high | ||
} | ||
], | ||
variables : [ | ||
vertex | ||
], | ||
depthWrite : false, | ||
depthCulling : false, | ||
domain: postprocess | ||
} | ||
|
||
vertex { | ||
void postProcessVertex(inout PostProcessVertexInputs postProcess) { | ||
postProcess.normalizedUV = uvToRenderTargetUV(postProcess.normalizedUV); | ||
postProcess.vertex.xy = postProcess.normalizedUV; | ||
} | ||
} | ||
|
||
fragment { | ||
|
||
void dummy(){} | ||
|
||
precision mediump float; | ||
precision highp int; | ||
|
||
#if defined(FILAMENT_HAS_FEATURE_TEXTURE_GATHER) | ||
#define gather textureGather | ||
#else | ||
vec4 gather(const mediump sampler2D color, highp vec2 p, const int comp) { | ||
highp ivec2 i = ivec2(p * materialParams.viewport.zw - 0.5); | ||
vec4 d; | ||
d[0] = texelFetchOffset(color, i, 0, ivec2(0, 1))[comp]; | ||
d[1] = texelFetchOffset(color, i, 0, ivec2(1, 1))[comp]; | ||
d[2] = texelFetchOffset(color, i, 0, ivec2(1, 0))[comp]; | ||
d[3] = texelFetchOffset(color, i, 0, ivec2(0, 0))[comp]; | ||
return d; | ||
} | ||
#endif | ||
|
||
/* | ||
* Operation modes: | ||
* RGBA -> 1 | ||
* RGBY -> 3 | ||
* LERP -> 4 | ||
*/ | ||
|
||
// SGSR cannot support translucency; | ||
// So we hijack the POST_PROCESS variant to select whether a luminance channel is present | ||
#if POST_PROCESS_OPAQUE | ||
# define OperationMode 1 | ||
#else | ||
# define OperationMode 3 | ||
#endif | ||
|
||
/* | ||
* If set, will use edge direction to improve visual quality | ||
* Expect a minimal cost increase | ||
*/ | ||
#define UseEdgeDirection | ||
#define EdgeThreshold 8.0 / 255.0 | ||
#define EdgeSharpness 2.0 | ||
|
||
#include "sgsr1_shader_mobile.fs" | ||
|
||
void postProcess(inout PostProcessInputs postProcess) { | ||
highp vec4 vp[1] = vec4[1]( materialParams.viewport ); | ||
postProcess.color = sgsr(materialParams_color, variable_vertex.xy, vp); | ||
} | ||
} |
Oops, something went wrong.
48a2c64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #8401, I think this change is related to the new crash.