Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7693b9e
mesh-clusters initial
Try Jan 13, 2024
0129835
move culling to dedicated class
Try Jan 14, 2024
5299ec0
cleanup some todo's
Try Jan 14, 2024
ff33337
+ gdr shadows
Try Jan 15, 2024
fe9eafc
gdr level object initial
Try Jan 16, 2024
080fda4
refactor & TODO's cleanup
Try Jan 20, 2024
c8ac488
some more culling
Try Jan 20, 2024
ef3bc1d
cluter+tess initial
Try Jan 21, 2024
64038fa
add depth-pass
Try Jan 21, 2024
07444cd
preFrameUpdate initial
Try Jan 22, 2024
b63a8c9
code cleanup & fix morp-descriptors
Try Jan 23, 2024
490568f
cluster-path initial
Try Jan 24, 2024
d2b7f45
free list for clusters
Try Jan 24, 2024
51f4123
refactor pfx
Try Jan 26, 2024
16d4173
generalize gdr shaders
Try Jan 28, 2024
a535bec
shader reorganization
Try Jan 28, 2024
27c9b71
reenable tesselation
Try Jan 28, 2024
1bfb26a
gdr + ghost shader
Try Jan 29, 2024
d3a8067
DrawStorage::Item::bounds & more shading
Try Jan 30, 2024
c03f5a4
enable texture scrolling for landscape
Try Jan 30, 2024
2b037ae
remove old stuff
Try Jan 30, 2024
b0added
refactorying
Try Jan 31, 2024
dcf8a36
refactor p2
Try Jan 31, 2024
2d2c5a4
refactor p3
Try Jan 31, 2024
21d3473
draw-commands in progress
Try Jan 31, 2024
87597e2
Update drawcommands.cpp
Try Jan 31, 2024
40e69e9
frame anim in progress
Try Feb 1, 2024
39a5edd
nonuniformEXT fixup
Try Feb 3, 2024
8ef9f67
mesh-shader initial
Try Feb 5, 2024
e18ea5e
non-bindless gdr in progress
Try Feb 5, 2024
6d4d888
fix double drawing
Try Feb 6, 2024
682af3a
non-bindless gdr in progress
Try Feb 6, 2024
f344867
non-bindless fallback in progress
Try Feb 8, 2024
ca3abe9
non-trivial landscape fixup
Try Feb 8, 2024
0656f05
mesh + tesselation fixup
Try Feb 10, 2024
5eb593e
Metal: mesh-shader is back
Try Feb 10, 2024
178dd6c
Update Tempest
Try Feb 10, 2024
0a4c1bf
relax some frame stutter
Try Feb 11, 2024
aaedf98
Update Tempest
Try Feb 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions game/commandline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ CommandLine::CommandLine(int argc, const char** argv) {
if(i<argc)
isMeshSh = (std::string_view(argv[i])!="0" && std::string_view(argv[i])!="false");
}
else if(arg=="-bl") {
// not to document - debug only
++i;
if(i<argc)
isBindlessSh = (std::string_view(argv[i])!="0" && std::string_view(argv[i])!="false");
}
else {
Log::i("unreacognized commandline option: \"", arg, "\"");
}
Expand Down
48 changes: 25 additions & 23 deletions game/commandline.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ class CommandLine {
std::u16string_view modPath() const { return gmod; }
std::u16string nestedPath(const std::initializer_list<const char16_t*> &name, Tempest::Dir::FileType type) const;

bool isDevMode() const { return devmode; }
bool isValidationMode() const { return isDebug; }
bool isWindowMode() const { return isWindow; }
bool isRayQuery() const { return isRQuery; }
bool isRtGi() const { return isGi; }
bool isMeshShading() const { return isMeshSh; }
bool doStartMenu() const { return !noMenu; }
bool doForceG1() const { return forceG1; }
bool doForceG2() const { return forceG2; }
bool doForceG2NR() const { return forceG2NR; }
std::string_view defaultSave() const { return saveDef; }
bool isDevMode() const { return devmode; }
bool isValidationMode() const { return isDebug; }
bool isWindowMode() const { return isWindow; }
bool isRayQuery() const { return isRQuery; }
bool isRtGi() const { return isGi; }
bool isMeshShading() const { return isMeshSh; }
bool isBindless() const { return isBindlessSh; }
bool doStartMenu() const { return !noMenu; }
bool doForceG1() const { return forceG1; }
bool doForceG2() const { return forceG2; }
bool doForceG2NR() const { return forceG2NR; }
std::string_view defaultSave() const { return saveDef; }

std::string wrldDef;

Expand All @@ -54,20 +55,21 @@ class CommandLine {
std::u16string gscript;
std::u16string gcutscene;
std::string saveDef;
bool devmode = false;
bool noMenu = false;
bool isWindow = false;
bool isDebug = false;
bool devmode = false;
bool noMenu = false;
bool isWindow = false;
bool isDebug = false;
#if defined(__OSX__)
bool isRQuery = false;
bool isMeshSh = false;
bool isRQuery = false;
bool isMeshSh = false;
#else
bool isRQuery = true;
bool isMeshSh = true;
bool isRQuery = true;
bool isMeshSh = true;
#endif
bool isGi = false;
bool forceG1 = false;
bool forceG2 = false;
bool forceG2NR = false;
bool isBindlessSh = true;
bool isGi = false;
bool forceG1 = false;
bool forceG2 = false;
bool forceG2NR = false;
};

11 changes: 11 additions & 0 deletions game/gothic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ static bool hasMeshShader() {
return false;
}

static bool hasBindless() {
const auto& p = Resources::device().properties();
if(p.descriptors.nonUniformIndexing && p.descriptors.maxTexture>=65000 && p.descriptors.maxStorage>=65000)
return true;
return false;
}

Gothic::Gothic() {
instance = this;

Expand Down Expand Up @@ -74,6 +81,10 @@ Gothic::Gothic() {
opts.doMeshShading = CommandLine::inst().isMeshShading();
}

if(hasBindless()) {
opts.doBindless = CommandLine::inst().isBindless();
}

wrldDef = CommandLine::inst().wrldDef;

baseIniFile.reset(new IniFile(nestedPath({u"system",u"Gothic.ini"},Dir::FT_File)));
Expand Down
1 change: 1 addition & 0 deletions game/gothic.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Gothic final {
bool doRayQuery = false;
bool doRtGi = false;
bool doMeshShading = false;
bool doBindless = false;

bool hideFocus = false;
float cameraFov = 67.5f;
Expand Down
97 changes: 97 additions & 0 deletions game/graphics/drawbuckets.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#include "drawbuckets.h"

#include <Tempest/Vec>

#include "graphics/mesh/submesh/staticmesh.h"
#include "graphics/mesh/submesh/animmesh.h"

using namespace Tempest;

DrawBuckets::Id::Id(DrawBuckets* owner, size_t id):owner(owner), id(uint16_t(id)) {
}

DrawBuckets::Id::Id(Id&& other) noexcept {
std::swap(owner, other.owner);
std::swap(id, other.id);
}

DrawBuckets::Id& DrawBuckets::Id::operator =(Id&& other) noexcept {
std::swap(owner, other.owner);
std::swap(id, other.id);
return *this;
}

DrawBuckets::Id::~Id() {
}


DrawBuckets::DrawBuckets() {
}

DrawBuckets::Id DrawBuckets::alloc(const Material& mat, const StaticMesh& mesh) {
for(size_t i=0; i<bucketsCpu.size(); ++i) {
auto& b = bucketsCpu[i];
if(b.staticMesh==&mesh && b.mat==mat)
return Id(this, i);
}

Bucket bx;
bx.staticMesh = &mesh;
bx.mat = mat;
bucketsCpu.emplace_back(std::move(bx));
bucketsDurtyBit = true;
return Id(this, bucketsCpu.size()-1);
}

DrawBuckets::Id DrawBuckets::alloc(const Material& mat, const AnimMesh& mesh) {
for(size_t i=0; i<bucketsCpu.size(); ++i) {
auto& b = bucketsCpu[i];
if(b.animMesh==&mesh && b.mat==mat)
return Id(this, i);
}

Bucket bx;
bx.animMesh = &mesh;
bx.mat = mat;

bucketsDurtyBit = true;
bucketsCpu.emplace_back(std::move(bx));
return Id(this, bucketsCpu.size()-1);
}

const std::vector<DrawBuckets::Bucket>& DrawBuckets::buckets() {
return bucketsCpu;
}

bool DrawBuckets::commit(Encoder<CommandBuffer>& cmd, uint8_t fId) {
if(!bucketsDurtyBit)
return false;
bucketsDurtyBit = false;

std::vector<BucketGpu> bucket;
for(auto& i:bucketsCpu) {
BucketGpu bx;
bx.texAniMapDirPeriod = i.mat.texAniMapDirPeriod;
bx.waveMaxAmplitude = i.mat.waveMaxAmplitude;
bx.alphaWeight = i.mat.alphaWeight;
bx.envMapping = i.mat.envMapping;
if(i.staticMesh!=nullptr) {
auto& bbox = i.staticMesh->bbox.bbox;
bx.bboxRadius = i.staticMesh->bbox.rConservative;
bx.bbox[0] = Vec4(bbox[0].x,bbox[0].y,bbox[0].z,0.f);
bx.bbox[1] = Vec4(bbox[1].x,bbox[1].y,bbox[1].z,0.f);
}
else if(i.animMesh!=nullptr) {
auto& bbox = i.animMesh->bbox.bbox;
bx.bboxRadius = i.animMesh->bbox.rConservative;
bx.bbox[0] = Vec4(bbox[0].x,bbox[0].y,bbox[0].z,0.f);
bx.bbox[1] = Vec4(bbox[1].x,bbox[1].y,bbox[1].z,0.f);
}
bucket.push_back(bx);
}

auto& device = Resources::device();
Resources::recycle(std::move(bucketsGpu));
bucketsGpu = device.ssbo(bucket);
return true;
}
65 changes: 65 additions & 0 deletions game/graphics/drawbuckets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#pragma once

#include <Tempest/StorageBuffer>

#include "material.h"

class StaticMesh;
class AnimMesh;

class DrawBuckets {
public:
DrawBuckets();

struct Bucket {
const StaticMesh* staticMesh = nullptr;
const AnimMesh* animMesh = nullptr;
Material mat;
};

class Id {
public:
Id() = default;
Id(DrawBuckets& owner):owner(&owner){}
Id(Id&& other) noexcept;
Id& operator = (Id&& other) noexcept;
~Id();

uint16_t toInt() const { return id; }

Bucket& operator * () { return owner->bucketsCpu[id]; }
Bucket* operator -> () { return &owner->bucketsCpu[id]; }

private:
Id(DrawBuckets* owner, size_t id);

DrawBuckets* owner = nullptr;
uint16_t id = 0;
friend class DrawBuckets;
};

Id alloc(const Material& mat, const StaticMesh& mesh);
Id alloc(const Material& mat, const AnimMesh& mesh);

const Bucket& operator[](size_t i) { return bucketsCpu[i]; }

auto ssbo() const -> const Tempest::StorageBuffer& { return bucketsGpu; }
auto buckets() -> const std::vector<Bucket>&;

bool commit(Tempest::Encoder<Tempest::CommandBuffer>& cmd, uint8_t fId);

private:
struct BucketGpu final {
Tempest::Vec4 bbox[2];
Tempest::Point texAniMapDirPeriod;
float bboxRadius = 0;
float waveMaxAmplitude = 0;
float alphaWeight = 1;
float envMapping = 0;
uint32_t padd[2] = {};
};

std::vector<Bucket> bucketsCpu;
Tempest::StorageBuffer bucketsGpu;
bool bucketsDurtyBit = false;
};
Loading