Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
"""Generate src/pipeline/SmaaLookupTables.cpp from the SMAA precomputed textures.
usage: py -3.11 -I scripts/generate-smaa-lookup-tables.py <AreaTex.dds> <SearchTex.dds>
The inputs are src/Effects/SMAA/AreaTex.dds and SearchTex.dds of SAOG0721/Magpie
d687997 (the SMAA precomputed textures of https://github.com/iryoku/smaa, MIT).
AreaTex.dds is 160x560 RGBA8 whose B/A channels are constant 0/255; only R/G are
used by SMAA, so the table keeps R8G8. SearchTex.dds is 64x16 R8. The payload
hashes are checked so a different texture version cannot slip in unnoticed.
"""
import hashlib
import struct
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT / 'src/pipeline/SmaaLookupTables.cpp'
AREA_RG_SHA256 = '35065cef2a02cabcad711d6bf430239ae64e27d71c4e4fa06f29cce2c992f0d2'
SEARCH_SHA256 = '3694eae5e9d44b8ebb4415a13f8c7b94dc08a2fc86658434d771c4610fe5744d'
def dds_payload(path, width, height, bits):
data = Path(path).read_bytes()
if data[:4] != b'DDS ' or struct.unpack_from('<I', data, 4)[0] != 124:
raise SystemExit(f'{path}: not a DDS file')
h, w = struct.unpack_from('<2I', data, 12)
fourcc = data[84:88]
rgb_bits = struct.unpack_from('<I', data, 88)[0]
if (w, h) != (width, height) or fourcc != b'\0\0\0\0' or rgb_bits != bits:
raise SystemExit(f'{path}: expected {width}x{height} uncompressed {bits}-bit, got {w}x{h} {fourcc} {rgb_bits}')
payload = data[128:]
if len(payload) != width * height * bits // 8:
raise SystemExit(f'{path}: payload is {len(payload)} bytes')
return payload
def rows(values):
return ',\n'.join(','.join(str(v) for v in values[i:i + 40]) for i in range(0, len(values), 40))
def main():
if len(sys.argv) != 3:
raise SystemExit(__doc__)
rgba = dds_payload(sys.argv[1], 160, 560, 32)
if set(rgba[2::4]) != {0} or set(rgba[3::4]) != {255}:
raise SystemExit('AreaTex: B/A channels are not the constant 0/255 this table drops')
area = bytes(b for i in range(0, len(rgba), 4) for b in rgba[i:i + 2])
search = dds_payload(sys.argv[2], 64, 16, 8)
for name, blob, expected in (('AreaTex RG', area, AREA_RG_SHA256), ('SearchTex', search, SEARCH_SHA256)):
got = hashlib.sha256(blob).hexdigest()
if got != expected:
raise SystemExit(f'{name}: SHA-256 {got} != {expected}')
text = f'''// Generated by scripts/generate-smaa-lookup-tables.py - do not edit.
// SMAA precomputed lookup textures (https://github.com/iryoku/smaa, MIT notice
// below), taken from src/Effects/SMAA/AreaTex.dds and SearchTex.dds of
// SAOG0721/Magpie d687997. AreaTex: 160x560 R8G8 (the DDS's constant B=0/A=255
// channels dropped), SHA-256 {AREA_RG_SHA256}.
// SearchTex: 64x16 R8, SHA-256 {SEARCH_SHA256}.
/**
* Copyright (C) 2013 Jorge Jimenez ([email protected])
* Copyright (C) 2013 Jose I. Echevarria ([email protected])
* Copyright (C) 2013 Belen Masia ([email protected])
* Copyright (C) 2013 Fernando Navarro ([email protected])
* Copyright (C) 2013 Diego Gutierrez ([email protected])
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to
* do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. As clarification, there
* is no requirement that the copyright notice and permission be included in
* binary distributions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "veyra/pipeline/SmaaLookupTables.h"
namespace veyra::pipeline::smaa {{
const uint8_t kAreaTex[kAreaTexBytes]={{
{rows(area)}
}};
const uint8_t kSearchTex[kSearchTexBytes]={{
{rows(search)}
}};
}}
'''
OUT.write_bytes(text.encode('utf-8'))
print(f'wrote {OUT} ({len(text)} bytes)')
main()