forked from mirrors/0ad
Adds compute shaders support and scaling with FSR.
Fixes #6842 Comments By: phosit, Stan Differential Revision: https://code.wildfiregames.com/D5218 This was SVN commit r28010.
This commit is contained in:
@@ -104,6 +104,9 @@ shadowscutoffdistance = 300.0
|
||||
; If true shadows cover the whole map instead of the camera frustum.
|
||||
shadowscovermap = false
|
||||
|
||||
renderer.scale = 1.0
|
||||
renderer.upscale.technique = "fsr"
|
||||
|
||||
vsync = false
|
||||
particles = true
|
||||
fog = true
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<effect>
|
||||
<technique>
|
||||
<require shaders="glsl"/>
|
||||
<compute shader="glsl/compute_downscale"/>
|
||||
</technique>
|
||||
<technique>
|
||||
<require shaders="spirv"/>
|
||||
<compute shader="spirv/compute_downscale"/>
|
||||
</technique>
|
||||
</effect>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<effect>
|
||||
<technique>
|
||||
<require shaders="glsl"/>
|
||||
<compute shader="glsl/compute_rcas"/>
|
||||
</technique>
|
||||
<technique>
|
||||
<require shaders="spirv"/>
|
||||
<compute shader="spirv/compute_rcas"/>
|
||||
</technique>
|
||||
</effect>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<effect>
|
||||
<technique>
|
||||
<require shaders="glsl"/>
|
||||
<compute shader="glsl/compute_upscale_fsr"/>
|
||||
</technique>
|
||||
<technique>
|
||||
<require shaders="spirv"/>
|
||||
<compute shader="spirv/compute_upscale_fsr"/>
|
||||
</technique>
|
||||
</effect>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<effect>
|
||||
<technique>
|
||||
<require shaders="glsl"/>
|
||||
<pass shader="glsl/upscale_bilinear">
|
||||
<depth test="FALSE" mask="false"/>
|
||||
</pass>
|
||||
</technique>
|
||||
<technique>
|
||||
<require shaders="spirv"/>
|
||||
<pass shader="spirv/upscale_bilinear">
|
||||
<depth test="FALSE" mask="false"/>
|
||||
</pass>
|
||||
</technique>
|
||||
</effect>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<effect>
|
||||
<technique>
|
||||
<require shaders="glsl"/>
|
||||
<pass shader="glsl/upscale_nearest">
|
||||
<depth test="FALSE" mask="false"/>
|
||||
</pass>
|
||||
</technique>
|
||||
<technique>
|
||||
<require shaders="spirv"/>
|
||||
<pass shader="spirv/upscale_nearest">
|
||||
<depth test="FALSE" mask="false"/>
|
||||
</pass>
|
||||
</technique>
|
||||
</effect>
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef INCLUDED_COMMON_COMPUTE
|
||||
#define INCLUDED_COMMON_COMPUTE
|
||||
|
||||
#include "common/descriptor_indexing.h"
|
||||
#include "common/texture.h"
|
||||
#include "common/uniform.h"
|
||||
|
||||
#if STAGE_COMPUTE
|
||||
|
||||
#if USE_SPIRV
|
||||
#define STORAGE_2D(LOCATION, FORMAT, NAME) \
|
||||
layout(set = 2, binding = LOCATION, FORMAT) uniform image2D NAME
|
||||
#else
|
||||
// We use offset to the binding slot for OpenGL to avoid overlapping with other
|
||||
// textures as OpenGL doesn't have sets.
|
||||
#define STORAGE_2D(LOCATION, FORMAT, NAME) \
|
||||
layout(binding = LOCATION, FORMAT) uniform image2D NAME
|
||||
#endif
|
||||
|
||||
#endif // STAGE_COMPUTE
|
||||
|
||||
#endif // INCLUDED_COMMON_COMPUTE
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef INCLUDED_COMMON_DESCRIPTOR_INDEXING
|
||||
#define INCLUDED_COMMON_DESCRIPTOR_INDEXING
|
||||
|
||||
#if USE_SPIRV && USE_DESCRIPTOR_INDEXING
|
||||
#extension GL_EXT_nonuniform_qualifier : enable
|
||||
const int DESCRIPTOR_INDEXING_SET_SIZE = 16384;
|
||||
layout (set = 0, binding = 0) uniform sampler2D textures2D[DESCRIPTOR_INDEXING_SET_SIZE];
|
||||
layout (set = 0, binding = 1) uniform samplerCube texturesCube[DESCRIPTOR_INDEXING_SET_SIZE];
|
||||
layout (set = 0, binding = 2) uniform sampler2DShadow texturesShadow[DESCRIPTOR_INDEXING_SET_SIZE];
|
||||
#endif // USE_SPIRV && USE_DESCRIPTOR_INDEXING
|
||||
|
||||
#endif // INCLUDED_COMMON_DESCRIPTOR_INDEXING
|
||||
@@ -1,19 +1,12 @@
|
||||
#ifndef INCLUDED_COMMON_FRAGMENT
|
||||
#define INCLUDED_COMMON_FRAGMENT
|
||||
|
||||
#include "common/descriptor_indexing.h"
|
||||
#include "common/texture.h"
|
||||
#include "common/uniform.h"
|
||||
|
||||
#if USE_SPIRV
|
||||
|
||||
#if USE_DESCRIPTOR_INDEXING
|
||||
#extension GL_EXT_nonuniform_qualifier : enable
|
||||
const int DESCRIPTOR_INDEXING_SET_SIZE = 16384;
|
||||
layout (set = 0, binding = 0) uniform sampler2D textures2D[DESCRIPTOR_INDEXING_SET_SIZE];
|
||||
layout (set = 0, binding = 1) uniform samplerCube texturesCube[DESCRIPTOR_INDEXING_SET_SIZE];
|
||||
layout (set = 0, binding = 2) uniform sampler2DShadow texturesShadow[DESCRIPTOR_INDEXING_SET_SIZE];
|
||||
#endif // USE_DESCRIPTOR_INDEXING
|
||||
|
||||
layout (location = 0) out vec4 fragmentColor;
|
||||
|
||||
#define OUTPUT_FRAGMENT_SINGLE_COLOR(COLOR) \
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define END_DRAW_TEXTURES
|
||||
#define NO_DRAW_TEXTURES
|
||||
|
||||
#if STAGE_FRAGMENT
|
||||
#if STAGE_FRAGMENT || STAGE_COMPUTE
|
||||
#define TEXTURE_2D(LOCATION, NAME) \
|
||||
layout (set = 1, binding = LOCATION) uniform sampler2D NAME;
|
||||
#define TEXTURE_2D_SHADOW(LOCATION, NAME) \
|
||||
@@ -60,7 +60,7 @@
|
||||
#define END_DRAW_TEXTURES
|
||||
#define NO_DRAW_TEXTURES
|
||||
|
||||
#if STAGE_FRAGMENT
|
||||
#if STAGE_FRAGMENT || STAGE_COMPUTE
|
||||
#define TEXTURE_2D(LOCATION, NAME) \
|
||||
uniform sampler2D NAME;
|
||||
#define TEXTURE_2D_SHADOW(LOCATION, NAME) \
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#version 430
|
||||
|
||||
#include "common/compute.h"
|
||||
|
||||
BEGIN_DRAW_TEXTURES
|
||||
TEXTURE_2D(0, inTex)
|
||||
END_DRAW_TEXTURES
|
||||
|
||||
BEGIN_DRAW_UNIFORMS
|
||||
UNIFORM(vec4, screenSize)
|
||||
END_DRAW_UNIFORMS
|
||||
|
||||
STORAGE_2D(0, rgba8, outTex);
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
void main()
|
||||
{
|
||||
ivec2 position = ivec2(gl_GlobalInvocationID.xy);
|
||||
if (any(greaterThanEqual(position, ivec2(screenSize.zw))))
|
||||
return;
|
||||
vec2 uv = (vec2(position) + vec2(0.5, 0.5)) / screenSize.zw;
|
||||
imageStore(outTex, position, texture(GET_DRAW_TEXTURE_2D(inTex), uv));
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<program type="glsl">
|
||||
|
||||
<compute file="glsl/compute_downscale.cs"/>
|
||||
|
||||
</program>
|
||||
@@ -0,0 +1,50 @@
|
||||
#version 430
|
||||
|
||||
#include "common/compute.h"
|
||||
|
||||
BEGIN_DRAW_TEXTURES
|
||||
TEXTURE_2D(0, inTex)
|
||||
END_DRAW_TEXTURES
|
||||
|
||||
BEGIN_DRAW_UNIFORMS
|
||||
UNIFORM(float, sharpness)
|
||||
END_DRAW_UNIFORMS
|
||||
|
||||
STORAGE_2D(0, rgba8, outTex);
|
||||
|
||||
#define A_GPU 1
|
||||
#define A_GLSL 1
|
||||
#define FSR_RCAS_DENOISE 1
|
||||
|
||||
// TODO: support 16-bit floats.
|
||||
#include "ffx_a.h"
|
||||
|
||||
#define FSR_RCAS_F 1
|
||||
AF4 FsrRcasLoadF(ASU2 p) { return texelFetch(GET_DRAW_TEXTURE_2D(inTex), ASU2(p), 0); }
|
||||
void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {}
|
||||
|
||||
#include "ffx_fsr1.h"
|
||||
|
||||
void CurrFilter(AU2 pos)
|
||||
{
|
||||
AU4 const0;
|
||||
FsrRcasCon(const0, sharpness);
|
||||
|
||||
AF3 c;
|
||||
FsrRcasF(c.r, c.g, c.b, pos, const0);
|
||||
imageStore(outTex, ASU2(pos), AF4(c, 1));
|
||||
}
|
||||
|
||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
||||
void main()
|
||||
{
|
||||
// Do remapping of local xy in workgroup for a more PS-like swizzle pattern.
|
||||
AU2 gxy = ARmp8x8(gl_LocalInvocationID.x) + AU2(gl_WorkGroupID.x << 4u, gl_WorkGroupID.y << 4u);
|
||||
CurrFilter(gxy);
|
||||
gxy.x += 8u;
|
||||
CurrFilter(gxy);
|
||||
gxy.y += 8u;
|
||||
CurrFilter(gxy);
|
||||
gxy.x -= 8u;
|
||||
CurrFilter(gxy);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<program type="glsl">
|
||||
|
||||
<compute file="glsl/compute_rcas.cs"/>
|
||||
|
||||
</program>
|
||||
@@ -0,0 +1,54 @@
|
||||
#version 430
|
||||
|
||||
#include "common/compute.h"
|
||||
|
||||
BEGIN_DRAW_TEXTURES
|
||||
TEXTURE_2D(0, inTex)
|
||||
END_DRAW_TEXTURES
|
||||
|
||||
BEGIN_DRAW_UNIFORMS
|
||||
UNIFORM(vec4, screenSize)
|
||||
END_DRAW_UNIFORMS
|
||||
|
||||
STORAGE_2D(0, rgba8, outTex);
|
||||
|
||||
#define A_GPU 1
|
||||
#define A_GLSL 1
|
||||
|
||||
// TODO: support 16-bit floats.
|
||||
#include "ffx_a.h"
|
||||
|
||||
#define FSR_EASU_F 1
|
||||
AF4 FsrEasuRF(AF2 p) { AF4 res = textureGather(GET_DRAW_TEXTURE_2D(inTex), p, 0); return res; }
|
||||
AF4 FsrEasuGF(AF2 p) { AF4 res = textureGather(GET_DRAW_TEXTURE_2D(inTex), p, 1); return res; }
|
||||
AF4 FsrEasuBF(AF2 p) { AF4 res = textureGather(GET_DRAW_TEXTURE_2D(inTex), p, 2); return res; }
|
||||
|
||||
#include "ffx_fsr1.h"
|
||||
|
||||
void CurrFilter(AU2 pos)
|
||||
{
|
||||
uvec4 const0, const1, const2, const3;
|
||||
FsrEasuCon(
|
||||
const0, const1, const2, const3,
|
||||
screenSize.x, screenSize.y,
|
||||
screenSize.x, screenSize.y,
|
||||
screenSize.z, screenSize.w);
|
||||
|
||||
AF3 c;
|
||||
FsrEasuF(c, pos, const0, const1, const2, const3);
|
||||
imageStore(outTex, ASU2(pos), AF4(c, 1));
|
||||
}
|
||||
|
||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
||||
void main()
|
||||
{
|
||||
// Do remapping of local xy in workgroup for a more PS-like swizzle pattern.
|
||||
AU2 gxy = ARmp8x8(gl_LocalInvocationID.x) + AU2(gl_WorkGroupID.x << 4u, gl_WorkGroupID.y << 4u);
|
||||
CurrFilter(gxy);
|
||||
gxy.x += 8u;
|
||||
CurrFilter(gxy);
|
||||
gxy.y += 8u;
|
||||
CurrFilter(gxy);
|
||||
gxy.x -= 8u;
|
||||
CurrFilter(gxy);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<program type="glsl">
|
||||
|
||||
<compute file="glsl/compute_upscale_fsr.cs"/>
|
||||
|
||||
</program>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
#version 120
|
||||
|
||||
#include "common/fragment.h"
|
||||
#include "common/stage.h"
|
||||
|
||||
BEGIN_DRAW_TEXTURES
|
||||
TEXTURE_2D(0, inTex)
|
||||
END_DRAW_TEXTURES
|
||||
|
||||
BEGIN_DRAW_UNIFORMS
|
||||
UNIFORM(vec4, screenSize)
|
||||
END_DRAW_UNIFORMS
|
||||
|
||||
VERTEX_OUTPUT(0, vec2, v_tex);
|
||||
|
||||
void main()
|
||||
{
|
||||
OUTPUT_FRAGMENT_SINGLE_COLOR(SAMPLE_2D(GET_DRAW_TEXTURE_2D(inTex), v_tex));
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<program type="glsl">
|
||||
|
||||
<vertex file="glsl/simple.vs">
|
||||
<stream name="pos" attribute="a_vertex"/>
|
||||
<stream name="uv0" attribute="a_uv0"/>
|
||||
</vertex>
|
||||
|
||||
<fragment file="glsl/upscale_bilinear.fs"/>
|
||||
|
||||
</program>
|
||||
@@ -0,0 +1,19 @@
|
||||
#version 130
|
||||
|
||||
#include "common/fragment.h"
|
||||
#include "common/stage.h"
|
||||
|
||||
BEGIN_DRAW_TEXTURES
|
||||
TEXTURE_2D(0, inTex)
|
||||
END_DRAW_TEXTURES
|
||||
|
||||
BEGIN_DRAW_UNIFORMS
|
||||
UNIFORM(vec4, screenSize)
|
||||
END_DRAW_UNIFORMS
|
||||
|
||||
VERTEX_OUTPUT(0, vec2, v_tex);
|
||||
|
||||
void main()
|
||||
{
|
||||
OUTPUT_FRAGMENT_SINGLE_COLOR(texelFetch(GET_DRAW_TEXTURE_2D(inTex), ivec2(v_tex * screenSize.xy), 0));
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<program type="glsl">
|
||||
|
||||
<vertex file="glsl/simple.vs">
|
||||
<stream name="pos" attribute="a_vertex"/>
|
||||
<stream name="uv0" attribute="a_uv0"/>
|
||||
</vertex>
|
||||
|
||||
<fragment file="glsl/upscale_nearest.fs"/>
|
||||
|
||||
</program>
|
||||
@@ -43,17 +43,26 @@
|
||||
<value>glsl</value>
|
||||
</attribute>
|
||||
|
||||
<element name="vertex">
|
||||
<attribute name="file"><text/></attribute>
|
||||
<zeroOrMore>
|
||||
<ref name="streamContent"/>
|
||||
</zeroOrMore>
|
||||
</element>
|
||||
<zeroOrMore>
|
||||
<element name="vertex">
|
||||
<attribute name="file"><text/></attribute>
|
||||
<zeroOrMore>
|
||||
<ref name="streamContent"/>
|
||||
</zeroOrMore>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
|
||||
<element name="fragment">
|
||||
<attribute name="file"><text/></attribute>
|
||||
</element>
|
||||
<zeroOrMore>
|
||||
<element name="fragment">
|
||||
<attribute name="file"><text/></attribute>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
|
||||
<zeroOrMore>
|
||||
<element name="compute">
|
||||
<attribute name="file"><text/></attribute>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
</group>
|
||||
</choice>
|
||||
</element>
|
||||
|
||||
@@ -333,7 +333,11 @@ function enableButtons()
|
||||
{
|
||||
const availableOps = {
|
||||
"==": (config, value) => config == value,
|
||||
"!=": (config, value) => config != value
|
||||
"!=": (config, value) => config != value,
|
||||
"<": (config, value) => +config < +value,
|
||||
"<=": (config, value) => +config <= +value,
|
||||
">": (config, value) => +config > +value,
|
||||
">=": (config, value) => +config >= +value
|
||||
};
|
||||
const op = availableOps[dependency.op] || availableOps["=="];
|
||||
return op(Engine.ConfigDB_GetValue("user", dependency.config), dependency.value);
|
||||
|
||||
@@ -111,6 +111,35 @@
|
||||
"tooltip": "Use screen-space post-processing filters (HDR, Bloom, DOF, etc).",
|
||||
"config": "postproc"
|
||||
},
|
||||
{
|
||||
"type": "dropdownNumber",
|
||||
"label": "Resolution scale",
|
||||
"tooltip": "A smaller scale makes rendering faster but produces a more blurry picture, a large scale makes rendering slower but produces a better picture.",
|
||||
"dependencies": ["postproc"],
|
||||
"config": "renderer.scale",
|
||||
"list": [
|
||||
{ "value": 0.5, "label": "50%" },
|
||||
{ "value": 0.75, "label": "75%" },
|
||||
{ "value": 0.875, "label": "87.5%" },
|
||||
{ "value": 1.00, "label": "100%" },
|
||||
{ "value": 1.25, "label": "125%" },
|
||||
{ "value": 1.50, "label": "150%" },
|
||||
{ "value": 1.75, "label": "175%" },
|
||||
{ "value": 2.00, "label": "200%" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "Upscale technique",
|
||||
"tooltip": "Technique defines performance and quality of upscaling process.",
|
||||
"dependencies": ["postproc", { "config": "renderer.scale", "op": "<", "value": 1.0 }],
|
||||
"config": "renderer.upscale.technique",
|
||||
"list": [
|
||||
{ "value": "fsr", "label": "FidelityFX Super Resolution 1.0", "tooltip": "Advanced upscale technique. For better results, use FSR with antialiasing enabled. Using it with the OpenGL backend may have some issues, consider using Vulkan backend instead." },
|
||||
{ "value": "bilinear", "label": "Bilinear", "tooltip": "Bilinear upscale technique. Produces a slightly blurry picture depending on the scale." },
|
||||
{ "value": "pixelated", "label": "Pixelated", "tooltip": "Simplest upscale technique. Used mostly for stylized effect." }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"label": "Shadows",
|
||||
|
||||
Reference in New Issue
Block a user