mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-08 03:33:44 -04:00
setting up vulkan part 1
This commit is contained in:
parent
935031a1e7
commit
060cb7f7d5
33 changed files with 1818 additions and 37 deletions
|
|
@ -13,23 +13,23 @@ set(SHADER_FILES
|
|||
texture_filtering/mmpx.frag
|
||||
texture_filtering/x_gradient.frag
|
||||
texture_filtering/y_gradient.frag
|
||||
antialiasing/opengl_fxaa.frag
|
||||
antialiasing/opengl_fxaa.vert
|
||||
antialiasing/opengl_smaa_pass0_pre.frag
|
||||
antialiasing/opengl_smaa_pass0_pre.vert
|
||||
antialiasing/opengl_smaa_pass0_post.frag
|
||||
antialiasing/opengl_smaa_pass0_post.vert
|
||||
antialiasing/opengl_smaa_pass1_pre.frag
|
||||
antialiasing/opengl_smaa_pass1_pre.vert
|
||||
antialiasing/opengl_smaa_pass1_post.frag
|
||||
antialiasing/opengl_smaa_pass1_post.vert
|
||||
antialiasing/opengl_smaa_pass2_pre.frag
|
||||
antialiasing/opengl_smaa_pass2_pre.vert
|
||||
antialiasing/opengl_smaa_pass2_post.frag
|
||||
antialiasing/opengl_smaa_pass2_post.vert
|
||||
antialiasing/OpenGL/opengl_fxaa.frag
|
||||
antialiasing/OpenGL/opengl_fxaa.vert
|
||||
antialiasing/OpenGL/opengl_smaa_pass0_pre.frag
|
||||
antialiasing/OpenGL/opengl_smaa_pass0_pre.vert
|
||||
antialiasing/OpenGL/opengl_smaa_pass0_post.frag
|
||||
antialiasing/OpenGL/opengl_smaa_pass0_post.vert
|
||||
antialiasing/OpenGL/opengl_smaa_pass1_pre.frag
|
||||
antialiasing/OpenGL/opengl_smaa_pass1_pre.vert
|
||||
antialiasing/OpenGL/opengl_smaa_pass1_post.frag
|
||||
antialiasing/OpenGL/opengl_smaa_pass1_post.vert
|
||||
antialiasing/OpenGL/opengl_smaa_pass2_pre.frag
|
||||
antialiasing/OpenGL/opengl_smaa_pass2_pre.vert
|
||||
antialiasing/OpenGL/opengl_smaa_pass2_post.frag
|
||||
antialiasing/OpenGL/opengl_smaa_pass2_post.vert
|
||||
antialiasing/OpenGL/opengl_smaa.hlsl
|
||||
scaling/opengl_area_sampling.frag
|
||||
scaling/opengl_area_sampling.vert
|
||||
antialiasing/smaa.hlsl
|
||||
full_screen_triangle.vert
|
||||
opengl_present.frag
|
||||
opengl_present.vert
|
||||
|
|
|
|||
256
src/video_core/host_shaders/antialiasing/Vulkan/vulkan_fxaa.frag
Normal file
256
src/video_core/host_shaders/antialiasing/Vulkan/vulkan_fxaa.frag
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright (c) 2011 NVIDIA Corporation. All rights reserved.
|
||||
*
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
|
||||
* *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
|
||||
* OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
|
||||
* OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT, OR
|
||||
* CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS
|
||||
* OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY
|
||||
* OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
|
||||
* EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*/
|
||||
|
||||
/*
|
||||
FXAA_PRESET - Choose compile-in knob preset 0-5.
|
||||
------------------------------------------------------------------------------
|
||||
FXAA_EDGE_THRESHOLD - The minimum amount of local contrast required
|
||||
to apply algorithm.
|
||||
1.0/3.0 - too little
|
||||
1.0/4.0 - good start
|
||||
1.0/8.0 - applies to more edges
|
||||
1.0/16.0 - overkill
|
||||
------------------------------------------------------------------------------
|
||||
FXAA_EDGE_THRESHOLD_MIN - Trims the algorithm from processing darks.
|
||||
Perf optimization.
|
||||
1.0/32.0 - visible limit (smaller isn't visible)
|
||||
1.0/16.0 - good compromise
|
||||
1.0/12.0 - upper limit (seeing artifacts)
|
||||
------------------------------------------------------------------------------
|
||||
FXAA_SEARCH_STEPS - Maximum number of search steps for end of span.
|
||||
------------------------------------------------------------------------------
|
||||
FXAA_SEARCH_THRESHOLD - Controls when to stop searching.
|
||||
1.0/4.0 - seems to be the best quality wise
|
||||
------------------------------------------------------------------------------
|
||||
FXAA_SUBPIX_TRIM - Controls sub-pixel aliasing removal.
|
||||
1.0/2.0 - low removal
|
||||
1.0/3.0 - medium removal
|
||||
1.0/4.0 - default removal
|
||||
1.0/8.0 - high removal
|
||||
0.0 - complete removal
|
||||
------------------------------------------------------------------------------
|
||||
FXAA_SUBPIX_CAP - Insures fine detail is not completely removed.
|
||||
This is important for the transition of sub-pixel detail,
|
||||
like fences and wires.
|
||||
3.0/4.0 - default (medium amount of filtering)
|
||||
7.0/8.0 - high amount of filtering
|
||||
1.0 - no capping of sub-pixel aliasing removal
|
||||
*/
|
||||
//? #version 450
|
||||
|
||||
layout(location = 0) in vec2 frag_tex_coord;
|
||||
layout(location = 0) out vec4 color;
|
||||
layout(binding = 0) uniform sampler2D color_texture;
|
||||
|
||||
uniform vec4 i_resolution;
|
||||
uniform int convert_colors;
|
||||
|
||||
#ifndef FXAA_PRESET
|
||||
#define FXAA_PRESET 5
|
||||
#endif
|
||||
#if (FXAA_PRESET == 3)
|
||||
#define FXAA_EDGE_THRESHOLD (1.0/8.0)
|
||||
#define FXAA_EDGE_THRESHOLD_MIN (1.0/16.0)
|
||||
#define FXAA_SEARCH_STEPS 16
|
||||
#define FXAA_SEARCH_THRESHOLD (1.0/4.0)
|
||||
#define FXAA_SUBPIX_CAP (3.0/4.0)
|
||||
#define FXAA_SUBPIX_TRIM (1.0/4.0)
|
||||
#endif
|
||||
#if (FXAA_PRESET == 4)
|
||||
#define FXAA_EDGE_THRESHOLD (1.0/8.0)
|
||||
#define FXAA_EDGE_THRESHOLD_MIN (1.0/24.0)
|
||||
#define FXAA_SEARCH_STEPS 24
|
||||
#define FXAA_SEARCH_THRESHOLD (1.0/4.0)
|
||||
#define FXAA_SUBPIX_CAP (3.0/4.0)
|
||||
#define FXAA_SUBPIX_TRIM (1.0/4.0)
|
||||
#endif
|
||||
#if (FXAA_PRESET == 5)
|
||||
#define FXAA_EDGE_THRESHOLD (1.0/8.0)
|
||||
#define FXAA_EDGE_THRESHOLD_MIN (1.0/24.0)
|
||||
#define FXAA_SEARCH_STEPS 32
|
||||
#define FXAA_SEARCH_THRESHOLD (1.0/4.0)
|
||||
#define FXAA_SUBPIX_CAP (3.0/4.0)
|
||||
#define FXAA_SUBPIX_TRIM (1.0/4.0)
|
||||
#endif
|
||||
|
||||
#define FXAA_SUBPIX_TRIM_SCALE (1.0/(1.0 - FXAA_SUBPIX_TRIM))
|
||||
|
||||
// Return the luma, the estimation of luminance from rgb inputs.
|
||||
// This approximates luma using one FMA instruction,
|
||||
// skipping normalization and tossing out blue.
|
||||
// FxaaLuma() will range 0.0 to 2.963210702.
|
||||
float FxaaLuma(vec3 rgb) {
|
||||
return rgb.y * (0.587/0.299) + rgb.x;
|
||||
}
|
||||
|
||||
vec3 FxaaLerp3(vec3 a, vec3 b, float amountOfA) {
|
||||
return (vec3(-amountOfA) * b) + ((a * vec3(amountOfA)) + b);
|
||||
}
|
||||
|
||||
vec4 FxaaTexOff(sampler2D tex, vec2 pos, ivec2 off, vec2 rcpFrame) {
|
||||
float x = pos.x + float(off.x) * rcpFrame.x;
|
||||
float y = pos.y + float(off.y) * rcpFrame.y;
|
||||
return texture(tex, vec2(x, y));
|
||||
}
|
||||
|
||||
// pos is the output of FxaaVertexShader interpolated across screen.
|
||||
// xy -> actual texture position {0.0 to 1.0}
|
||||
// rcpFrame should be a uniform equal to {1.0/frameWidth, 1.0/frameHeight}
|
||||
vec3 FxaaPixelShader(vec2 pos, sampler2D tex, vec2 rcpFrame)
|
||||
{
|
||||
vec3 rgbN = FxaaTexOff(tex, pos.xy, ivec2( 0,-1), rcpFrame).xyz;
|
||||
vec3 rgbW = FxaaTexOff(tex, pos.xy, ivec2(-1, 0), rcpFrame).xyz;
|
||||
vec3 rgbM = FxaaTexOff(tex, pos.xy, ivec2( 0, 0), rcpFrame).xyz;
|
||||
vec3 rgbE = FxaaTexOff(tex, pos.xy, ivec2( 1, 0), rcpFrame).xyz;
|
||||
vec3 rgbS = FxaaTexOff(tex, pos.xy, ivec2( 0, 1), rcpFrame).xyz;
|
||||
|
||||
float lumaN = FxaaLuma(rgbN);
|
||||
float lumaW = FxaaLuma(rgbW);
|
||||
float lumaM = FxaaLuma(rgbM);
|
||||
float lumaE = FxaaLuma(rgbE);
|
||||
float lumaS = FxaaLuma(rgbS);
|
||||
float rangeMin = min(lumaM, min(min(lumaN, lumaW), min(lumaS, lumaE)));
|
||||
float rangeMax = max(lumaM, max(max(lumaN, lumaW), max(lumaS, lumaE)));
|
||||
|
||||
float range = rangeMax - rangeMin;
|
||||
if(range < max(FXAA_EDGE_THRESHOLD_MIN, rangeMax * FXAA_EDGE_THRESHOLD))
|
||||
{
|
||||
return rgbM;
|
||||
}
|
||||
|
||||
vec3 rgbL = rgbN + rgbW + rgbM + rgbE + rgbS;
|
||||
|
||||
float lumaL = (lumaN + lumaW + lumaE + lumaS) * 0.25;
|
||||
float rangeL = abs(lumaL - lumaM);
|
||||
float blendL = max(0.0, (rangeL / range) - FXAA_SUBPIX_TRIM) * FXAA_SUBPIX_TRIM_SCALE;
|
||||
blendL = min(FXAA_SUBPIX_CAP, blendL);
|
||||
|
||||
vec3 rgbNW = FxaaTexOff(tex, pos.xy, ivec2(-1,-1), rcpFrame).xyz;
|
||||
vec3 rgbNE = FxaaTexOff(tex, pos.xy, ivec2( 1,-1), rcpFrame).xyz;
|
||||
vec3 rgbSW = FxaaTexOff(tex, pos.xy, ivec2(-1, 1), rcpFrame).xyz;
|
||||
vec3 rgbSE = FxaaTexOff(tex, pos.xy, ivec2( 1, 1), rcpFrame).xyz;
|
||||
rgbL += (rgbNW + rgbNE + rgbSW + rgbSE);
|
||||
rgbL *= vec3(1.0/9.0);
|
||||
|
||||
float lumaNW = FxaaLuma(rgbNW);
|
||||
float lumaNE = FxaaLuma(rgbNE);
|
||||
float lumaSW = FxaaLuma(rgbSW);
|
||||
float lumaSE = FxaaLuma(rgbSE);
|
||||
|
||||
float edgeVert =
|
||||
abs((0.25 * lumaNW) + (-0.5 * lumaN) + (0.25 * lumaNE)) +
|
||||
abs((0.50 * lumaW ) + (-1.0 * lumaM) + (0.50 * lumaE )) +
|
||||
abs((0.25 * lumaSW) + (-0.5 * lumaS) + (0.25 * lumaSE));
|
||||
float edgeHorz =
|
||||
abs((0.25 * lumaNW) + (-0.5 * lumaW) + (0.25 * lumaSW)) +
|
||||
abs((0.50 * lumaN ) + (-1.0 * lumaM) + (0.50 * lumaS )) +
|
||||
abs((0.25 * lumaNE) + (-0.5 * lumaE) + (0.25 * lumaSE));
|
||||
|
||||
bool horzSpan = edgeHorz >= edgeVert;
|
||||
float lengthSign = horzSpan ? -rcpFrame.y : -rcpFrame.x;
|
||||
|
||||
if(!horzSpan)
|
||||
{
|
||||
lumaN = lumaW;
|
||||
lumaS = lumaE;
|
||||
}
|
||||
|
||||
float gradientN = abs(lumaN - lumaM);
|
||||
float gradientS = abs(lumaS - lumaM);
|
||||
lumaN = (lumaN + lumaM) * 0.5;
|
||||
lumaS = (lumaS + lumaM) * 0.5;
|
||||
|
||||
if (gradientN < gradientS)
|
||||
{
|
||||
lumaN = lumaS;
|
||||
lumaN = lumaS;
|
||||
gradientN = gradientS;
|
||||
lengthSign *= -1.0;
|
||||
}
|
||||
|
||||
vec2 posN;
|
||||
posN.x = pos.x + (horzSpan ? 0.0 : lengthSign * 0.5);
|
||||
posN.y = pos.y + (horzSpan ? lengthSign * 0.5 : 0.0);
|
||||
|
||||
gradientN *= FXAA_SEARCH_THRESHOLD;
|
||||
|
||||
vec2 posP = posN;
|
||||
vec2 offNP = horzSpan ? vec2(rcpFrame.x, 0.0) : vec2(0.0, rcpFrame.y);
|
||||
float lumaEndN = lumaN;
|
||||
float lumaEndP = lumaN;
|
||||
bool doneN = false;
|
||||
bool doneP = false;
|
||||
posN += offNP * vec2(-1.0, -1.0);
|
||||
posP += offNP * vec2( 1.0, 1.0);
|
||||
|
||||
for(int i = 0; i < FXAA_SEARCH_STEPS; i++) {
|
||||
if(!doneN)
|
||||
{
|
||||
lumaEndN = FxaaLuma(texture(tex, posN.xy).xyz);
|
||||
}
|
||||
if(!doneP)
|
||||
{
|
||||
lumaEndP = FxaaLuma(texture(tex, posP.xy).xyz);
|
||||
}
|
||||
|
||||
doneN = doneN || (abs(lumaEndN - lumaN) >= gradientN);
|
||||
doneP = doneP || (abs(lumaEndP - lumaN) >= gradientN);
|
||||
|
||||
if(doneN && doneP)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(!doneN)
|
||||
{
|
||||
posN -= offNP;
|
||||
}
|
||||
if(!doneP)
|
||||
{
|
||||
posP += offNP;
|
||||
}
|
||||
}
|
||||
|
||||
float dstN = horzSpan ? pos.x - posN.x : pos.y - posN.y;
|
||||
float dstP = horzSpan ? posP.x - pos.x : posP.y - pos.y;
|
||||
bool directionN = dstN < dstP;
|
||||
lumaEndN = directionN ? lumaEndN : lumaEndP;
|
||||
|
||||
if(((lumaM - lumaN) < 0.0) == ((lumaEndN - lumaN) < 0.0))
|
||||
{
|
||||
lengthSign = 0.0;
|
||||
}
|
||||
|
||||
|
||||
float spanLength = (dstP + dstN);
|
||||
dstN = directionN ? dstN : dstP;
|
||||
float subPixelOffset = (0.5 + (dstN * (-1.0/spanLength))) * lengthSign;
|
||||
vec3 rgbF = texture(tex, vec2(
|
||||
pos.x + (horzSpan ? 0.0 : subPixelOffset),
|
||||
pos.y + (horzSpan ? subPixelOffset : 0.0))).xyz;
|
||||
return FxaaLerp3(rgbL, rgbF, blendL);
|
||||
}
|
||||
|
||||
vec3 sRGBToLinear(vec3 c) {
|
||||
return mix(c / 12.92, pow((c + 0.055) / 1.055, vec3(2.4)), step(0.04045, c));
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pixel = vec4(FxaaPixelShader(frag_tex_coord, color_texture, vec2(i_resolution.z, i_resolution.w)), 1.0) * 1.0;
|
||||
if (convert_colors == 1){
|
||||
pixel = vec4(sRGBToLinear(pixel.rgb), pixel.a);
|
||||
}
|
||||
color = pixel;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
//? #version 450
|
||||
layout(location = 0) in vec2 vert_position;
|
||||
layout(location = 1) in vec2 vert_tex_coord;
|
||||
layout(location = 0) out vec2 frag_tex_coord;
|
||||
|
||||
uniform vec4 i_resolution;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(vert_position, 0.0, 1.0);
|
||||
frag_tex_coord = vert_tex_coord;
|
||||
}
|
||||
|
||||
1361
src/video_core/host_shaders/antialiasing/Vulkan/vulkan_smaa.hlsl
Normal file
1361
src/video_core/host_shaders/antialiasing/Vulkan/vulkan_smaa.hlsl
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,7 @@
|
|||
void main() {
|
||||
if (SMAA_EDT == 0.0) {
|
||||
color = vec4(SMAALumaEdgeDetectionPS(frag_tex_coord, offset, color_texture), 0.0, 0.0);
|
||||
} else if (SMAA_EDT <= 1.0) {
|
||||
color = vec4(SMAAColorEdgeDetectionPS(frag_tex_coord, offset, color_texture), 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
void main() {
|
||||
gl_Position = vec4(vert_position, 0.0, 1.0);
|
||||
frag_tex_coord = vert_tex_coord;
|
||||
SMAAEdgeDetectionVS(vert_tex_coord, offset);
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
//? #version 450
|
||||
// SPDX-License-Identifier: Unlicense
|
||||
//-----------------------------------------------------------------------------
|
||||
// Edge Detection Shaders (First Pass)
|
||||
|
||||
uniform vec4 i_resolution;
|
||||
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)
|
||||
#define SMAA_GLSL_4
|
||||
#define SMAA_PRESET_ULTRA
|
||||
#define SMAA_EDT 1.0
|
||||
|
||||
layout(location = 0) in vec2 frag_tex_coord;
|
||||
layout(location = 1) in vec4 offset[3];
|
||||
layout(location = 0) out vec4 color;
|
||||
layout(binding = 0) uniform sampler2D color_texture;
|
||||
|
||||
#define SMAA_INCLUDE_VS 0
|
||||
//#include "SMAA.hlsl"
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
//? #version 450
|
||||
// SPDX-License-Identifier: Unlicense
|
||||
//-----------------------------------------------------------------------------
|
||||
// Edge Detection Shaders (First Pass)
|
||||
|
||||
uniform vec4 i_resolution;
|
||||
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)
|
||||
#define SMAA_GLSL_4
|
||||
#define SMAA_PRESET_ULTRA
|
||||
#define SMAA_EDT 1.0
|
||||
|
||||
layout(location = 0) in vec2 vert_position;
|
||||
layout(location = 1) in vec2 vert_tex_coord;
|
||||
layout(location = 0) out vec2 frag_tex_coord;
|
||||
layout(location = 1) out vec4 offset[3];
|
||||
|
||||
#define SMAA_INCLUDE_PS 0
|
||||
//#include "SMAA.hlsl"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
void main() {
|
||||
vec4 subsampleIndices = vec4(0.0);
|
||||
color = SMAABlendingWeightCalculationPS(frag_tex_coord, pixcoord, offset, color_texture, areaTex, searchTex, subsampleIndices);
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
void main() {
|
||||
gl_Position = vec4(vert_position, 0.0, 1.0);
|
||||
frag_tex_coord = vert_tex_coord;
|
||||
SMAABlendingWeightCalculationVS(vert_tex_coord, pixcoord, offset);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
//? #version 450
|
||||
// SPDX-License-Identifier: Unlicense
|
||||
//-----------------------------------------------------------------------------
|
||||
// Blending Weight Calculation Shader (Second Pass)
|
||||
|
||||
uniform vec4 i_resolution;
|
||||
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)
|
||||
#define SMAA_GLSL_4
|
||||
#define SMAA_PRESET_ULTRA
|
||||
#define SMAA_EDT 1.0
|
||||
|
||||
layout(location = 0) in vec2 frag_tex_coord;
|
||||
layout(location = 1) in vec2 pixcoord;
|
||||
layout(location = 2) in vec4 offset[3];
|
||||
layout(location = 0) out vec4 color;
|
||||
layout(binding = 0) uniform sampler2D color_texture;
|
||||
uniform sampler2D areaTex;
|
||||
uniform sampler2D searchTex;
|
||||
|
||||
#define SMAA_INCLUDE_VS 0
|
||||
//#include "SMAA.hlsl"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
//? #version 450
|
||||
// SPDX-License-Identifier: Unlicense
|
||||
//-----------------------------------------------------------------------------
|
||||
// Blending Weight Calculation Shader (Second Pass)
|
||||
|
||||
uniform vec4 i_resolution;
|
||||
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)
|
||||
#define SMAA_GLSL_4
|
||||
#define SMAA_PRESET_ULTRA
|
||||
#define SMAA_EDT 1.0
|
||||
|
||||
layout(location = 0) in vec2 vert_position;
|
||||
layout(location = 1) in vec2 vert_tex_coord;
|
||||
layout(location = 0) out vec2 frag_tex_coord;
|
||||
layout(location = 1) out vec2 pixcoord;
|
||||
layout(location = 2) out vec4 offset[3];
|
||||
|
||||
#define SMAA_INCLUDE_PS 0
|
||||
//#include "SMAA.hlsl"
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
vec3 LinearTosRGB(vec3 c) {
|
||||
return mix(c * 12.92, 1.055 * pow(c, vec3(1.0/2.4)) - 0.055, step(0.0031308, c));
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 pixel = SMAANeighborhoodBlendingPS(frag_tex_coord, offset, SMAA_Input, color_texture);
|
||||
if (convert_colors == 2){
|
||||
pixel = vec4(LinearTosRGB(pixel.rgb), pixel.a);
|
||||
}
|
||||
color = pixel;
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
void main() {
|
||||
gl_Position = vec4(vert_position, 0.0, 1.0);
|
||||
frag_tex_coord = vert_tex_coord;
|
||||
SMAANeighborhoodBlendingVS(vert_tex_coord, offset);
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
//? #version 450
|
||||
// SPDX-License-Identifier: Unlicense
|
||||
//-----------------------------------------------------------------------------
|
||||
// Neighborhood Blending Shader (Third Pass)
|
||||
|
||||
uniform vec4 i_resolution;
|
||||
uniform int convert_colors;
|
||||
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)
|
||||
#define SMAA_GLSL_4
|
||||
|
||||
layout(location = 0) in vec2 frag_tex_coord;
|
||||
layout(location = 1) in vec4 offset;
|
||||
layout(location = 0) out vec4 color;
|
||||
layout(binding = 0) uniform sampler2D color_texture;
|
||||
uniform sampler2D SMAA_Input;
|
||||
|
||||
#define SMAA_INCLUDE_VS 0
|
||||
//#include "SMAA.hlsl"
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
//? #version 450
|
||||
// SPDX-License-Identifier: Unlicense
|
||||
//-----------------------------------------------------------------------------
|
||||
// Neighborhood Blending Shader (Third Pass)
|
||||
|
||||
uniform vec4 i_resolution;
|
||||
#define SMAA_RT_METRICS vec4(i_resolution.z, i_resolution.w, i_resolution.x, i_resolution.y)
|
||||
#define SMAA_GLSL_4
|
||||
|
||||
layout(location = 0) in vec2 vert_position;
|
||||
layout(location = 1) in vec2 vert_tex_coord;
|
||||
layout(location = 0) out vec2 frag_tex_coord;
|
||||
layout(location = 1) out vec4 offset;
|
||||
|
||||
#define SMAA_INCLUDE_PS 0
|
||||
//#include "SMAA.hlsl"
|
||||
|
|
@ -25,21 +25,21 @@
|
|||
#include "video_core/host_shaders/opengl_simple_present_frag.h"
|
||||
#include "video_core/host_shaders/opengl_simple_present_vert.h"
|
||||
|
||||
#include "video_core/host_shaders/antialiasing/opengl_fxaa_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_fxaa_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass0_pre_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass0_pre_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass0_post_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass0_post_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass1_pre_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass1_pre_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass1_post_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass1_post_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass2_pre_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass2_pre_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass2_post_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/opengl_smaa_pass2_post_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/smaa_hlsl.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_fxaa_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_fxaa_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass0_pre_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass0_pre_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass0_post_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass0_post_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass1_pre_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass1_pre_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass1_post_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass1_post_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass2_pre_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass2_pre_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass2_post_frag.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_pass2_post_vert.h"
|
||||
#include "video_core/host_shaders/antialiasing/OpenGL/opengl_smaa_hlsl.h"
|
||||
#include "video_core/host_shaders/antialiasing/AreaTex.h"
|
||||
#include "video_core/host_shaders/antialiasing/SearchTex.h"
|
||||
#include "video_core/host_shaders/scaling/opengl_area_sampling_frag.h"
|
||||
|
|
@ -501,31 +501,31 @@ void RendererOpenGL::ReloadShader(Settings::StereoRenderOption render_3d) {
|
|||
|
||||
std::string SMAA_PASS_0_shader_frag_data = fragment_shader_precision_OES;
|
||||
SMAA_PASS_0_shader_frag_data += HostShaders::OPENGL_SMAA_PASS0_PRE_FRAG;
|
||||
SMAA_PASS_0_shader_frag_data += HostShaders::SMAA_HLSL;
|
||||
SMAA_PASS_0_shader_frag_data += HostShaders::OPENGL_SMAA_HLSL;
|
||||
SMAA_PASS_0_shader_frag_data += HostShaders::OPENGL_SMAA_PASS0_POST_FRAG;
|
||||
std::string SMAA_PASS_0_shader_vert_data;
|
||||
SMAA_PASS_0_shader_vert_data += HostShaders::OPENGL_SMAA_PASS0_PRE_VERT;
|
||||
SMAA_PASS_0_shader_vert_data += HostShaders::SMAA_HLSL;
|
||||
SMAA_PASS_0_shader_vert_data += HostShaders::OPENGL_SMAA_HLSL;
|
||||
SMAA_PASS_0_shader_vert_data += HostShaders::OPENGL_SMAA_PASS0_POST_VERT;
|
||||
SMAA_PASS_0_shader.Create(SMAA_PASS_0_shader_vert_data, SMAA_PASS_0_shader_frag_data);
|
||||
|
||||
std::string SMAA_PASS_1_shader_frag_data = fragment_shader_precision_OES;
|
||||
SMAA_PASS_1_shader_frag_data += HostShaders::OPENGL_SMAA_PASS1_PRE_FRAG;
|
||||
SMAA_PASS_1_shader_frag_data += HostShaders::SMAA_HLSL;
|
||||
SMAA_PASS_1_shader_frag_data += HostShaders::OPENGL_SMAA_HLSL;
|
||||
SMAA_PASS_1_shader_frag_data += HostShaders::OPENGL_SMAA_PASS1_POST_FRAG;
|
||||
std::string SMAA_PASS_1_shader_vert_data;
|
||||
SMAA_PASS_1_shader_vert_data += HostShaders::OPENGL_SMAA_PASS1_PRE_VERT;
|
||||
SMAA_PASS_1_shader_vert_data += HostShaders::SMAA_HLSL;
|
||||
SMAA_PASS_1_shader_vert_data += HostShaders::OPENGL_SMAA_HLSL;
|
||||
SMAA_PASS_1_shader_vert_data += HostShaders::OPENGL_SMAA_PASS1_POST_VERT;
|
||||
SMAA_PASS_1_shader.Create(SMAA_PASS_1_shader_vert_data, SMAA_PASS_1_shader_frag_data);
|
||||
|
||||
std::string SMAA_PASS_2_shader_frag_data = fragment_shader_precision_OES;
|
||||
SMAA_PASS_2_shader_frag_data += HostShaders::OPENGL_SMAA_PASS2_PRE_FRAG;
|
||||
SMAA_PASS_2_shader_frag_data += HostShaders::SMAA_HLSL;
|
||||
SMAA_PASS_2_shader_frag_data += HostShaders::OPENGL_SMAA_HLSL;
|
||||
SMAA_PASS_2_shader_frag_data += HostShaders::OPENGL_SMAA_PASS2_POST_FRAG;
|
||||
std::string SMAA_PASS_2_shader_vert_data;
|
||||
SMAA_PASS_2_shader_vert_data += HostShaders::OPENGL_SMAA_PASS2_PRE_VERT;
|
||||
SMAA_PASS_2_shader_vert_data += HostShaders::SMAA_HLSL;
|
||||
SMAA_PASS_2_shader_vert_data += HostShaders::OPENGL_SMAA_HLSL;
|
||||
SMAA_PASS_2_shader_vert_data += HostShaders::OPENGL_SMAA_PASS2_POST_VERT;
|
||||
SMAA_PASS_2_shader.Create(SMAA_PASS_2_shader_vert_data, SMAA_PASS_2_shader_frag_data);
|
||||
|
||||
|
|
|
|||
|
|
@ -62,8 +62,12 @@ struct PresentUniformData {
|
|||
int screen_id_r = 0;
|
||||
int layer = 0;
|
||||
int reverse_interlaced = 0;
|
||||
int convert_colors;
|
||||
int areatex;
|
||||
int searchtex;
|
||||
int smaa_input;
|
||||
};
|
||||
static_assert(sizeof(PresentUniformData) == 112,
|
||||
static_assert(sizeof(PresentUniformData) == 128,
|
||||
"PresentUniformData does not structure in shader!");
|
||||
|
||||
class RendererVulkan : public VideoCore::RendererBase {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue