Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
c0b454e
Remove redundant __GNU__ macro
floooh Jan 5, 2018
faf4c7e
Add sokol dependency
floooh Jan 5, 2018
1e4a9ee
Add sokolGfxBackend class
floooh Jan 5, 2018
76eab6d
Some more sokol_gfx backend implementation
floooh Jan 6, 2018
db3122c
start moving functionality into gfxBackend
floooh Jan 6, 2018
3b63a38
remove obsolete platform Gfx sources
floooh Jan 8, 2018
ee141a7
more Gfx file cleanup
floooh Jan 8, 2018
a25d14e
more sokol_gfx integration
floooh Jan 8, 2018
bf3acce
more sokol_gfx integration
floooh Jan 9, 2018
9077ff0
sokol_gfx migration: Triangle sample working
floooh Jan 10, 2018
95180ac
More sokol_gfx migration:
floooh Jan 11, 2018
85f22a4
MeshBuilder: don't init IndexBufferSetup if not indices requested
floooh Jan 11, 2018
43c6801
Dbg: fix debug text rendering for sokol-gfx changes
floooh Jan 11, 2018
31dd32c
Texture creation via sokol_gfx, PrimitiveTypes and DbgText sample wor…
floooh Jan 11, 2018
1bffb1e
Gfx: remove combined color/depth render target textures
floooh Jan 13, 2018
c2c2860
More sokol-gfx migration
floooh Jan 13, 2018
2aa6d69
Make resource creation more convenient with separate builder classes
floooh Jan 14, 2018
fd544a7
Gfx: more resource creation simplification
floooh Jan 14, 2018
9cec193
Fix SeparateBuffers sample for new resource creation
floooh Jan 14, 2018
abcbe8b
Another attempt at Gfx resource setup
floooh Jan 14, 2018
4cff151
More Gfx resource builder changes
floooh Jan 15, 2018
866b1cb
ShapeBuilder: fix cleanup bug after ShapeBuilder::Build()
floooh Jan 16, 2018
a09a4ca
sokol-migration: render passes, resource builder tweaks, and more sam…
floooh Jan 16, 2018
b9382b6
more samples ported to new resource creation
floooh Jan 16, 2018
a464b6c
Renamed Buffer to MemoryBuffer
floooh Jan 17, 2018
9cd3ffc
All samples working on sokol GL backend, except the ones with resourc…
floooh Jan 17, 2018
99c2caf
new async texture loading, TextureCube sample working
floooh Jan 18, 2018
163b471
Gfx: add resource state query functions
floooh Jan 19, 2018
277faca
Update DDSTextureLoading sample
floooh Jan 19, 2018
8e6bc0a
All samples updated
floooh Jan 19, 2018
c0d52d2
Started with sokol Metal backend migration
floooh Jan 20, 2018
f815f55
More sokol-migration for Metal backend
floooh Jan 21, 2018
4c19268
minor Visual Studio fixes
floooh Jan 22, 2018
d87cb9a
Fix emscripten build
floooh Jan 22, 2018
59f0ed1
Fix iOS and Android build, and some Gfx code cleanup
floooh Jan 23, 2018
179e88e
fix a new GCC warning in ConvertUTF
floooh Jan 23, 2018
ecd88c6
Start with D3D11 sokol-migration
floooh Jan 23, 2018
d0b1f31
Fix Linux build
floooh Jan 23, 2018
1090f33
Updated Windows oryol-shdc.exe
floooh Jan 23, 2018
4372bc1
D3D11: vertex layout with semantic name and index
floooh Jan 24, 2018
7fe23d5
Fix for new vertex layout definition in sokol_gfx, all GL and Metal s…
floooh Jan 27, 2018
e18123a
Gfx: cleanup directory structure a bit
floooh Jan 28, 2018
0709527
Gfx: builder methods for PassAction
floooh Jan 28, 2018
2468138
Remove obsolete GfxConfig.h
floooh Jan 28, 2018
fd86fae
New Gfx resource builder pattern
floooh Jan 28, 2018
b677c1b
fix win/d3d11DisplayMgr for recent Gfx module changes
floooh Jan 31, 2018
7f1fb7a
New approach to Gfx Desc structure setup (only GfxDesc for now)
floooh Apr 16, 2018
1cdb97d
Move all Gfx Desc functions to new 'integrated builder methods'
floooh Apr 17, 2018
28ee7f5
fixes for Metal
floooh Apr 17, 2018
efcc720
GfxTypes.h: remove some obsolete constants
floooh Apr 18, 2018
4437b28
GfxTypes: minor code cleanup
floooh Apr 21, 2018
456e469
cleanup Asset module APIs
floooh Apr 21, 2018
51fc0a0
DbgSetup => DbgDesc with builder methods
floooh Apr 22, 2018
98381f1
Cleanup Resource module
floooh Apr 22, 2018
594f5f0
iOS: Gfx module compile fixes
floooh Apr 22, 2018
62f2b47
Emscripten: Gfx module compile fixes
floooh Apr 22, 2018
4a95fdf
InputSetup => InputDesc
floooh Apr 22, 2018
4abea44
IOSetup => IODesc
floooh Apr 22, 2018
08d39ec
D3D11: fix compile errors
floooh Apr 23, 2018
5be0b69
Gfx: Remove static New from VertexLayout and PassAction
floooh Apr 23, 2018
5115a5c
Merge branch 'master' into sokol-gfx
floooh Apr 23, 2018
21e627c
BufferTest => MemoryBufferTest
floooh Apr 23, 2018
6050edf
Fix a header dependency problem in IOTypes.h/.cc
floooh Apr 24, 2018
b412fac
Remove an unnecessary include
floooh Apr 24, 2018
57ac2e8
Add a FullscreenQuadBuilder class in Assets module
floooh Apr 24, 2018
98d7216
Gfx: Remove PassAttrs method
floooh Apr 24, 2018
ee1af4a
Dbg: add width/height to Dbg::DrawTextBuffer()
floooh Apr 24, 2018
d926cdb
Minor fixes
floooh Apr 24, 2018
765c790
Resource module: Fix the broken Locator::operator<()
floooh Apr 25, 2018
9d02dff
ResourceRegistry: add a DumpDebugInfo method
floooh Apr 25, 2018
e877685
Fix bug in GLES3->GLES2 fallback path
floooh May 1, 2018
5d243ba
iOS Metal: fix small compile error
floooh May 3, 2018
bac124f
fix a comment
floooh May 5, 2018
e3657d1
Android fixes
floooh May 7, 2018
9304fff
new sample webpage design
floooh May 9, 2018
8d857a9
modernize samples webpage
floooh May 10, 2018
e654e03
fix an Obj-C interface definition
floooh May 11, 2018
16db52a
Add sokol link to webpage
floooh May 11, 2018
ee0f6ab
use SOKOL_METAL instead of SOKOL_METAL_IOS/MACOS
floooh May 11, 2018
8f87c38
iOS: remove unused onDrawRequested() method decl
floooh May 15, 2018
42db1b1
Start with documentation fixes for sokol-gfx migration
floooh May 22, 2018
784a3e8
sample webpage simplifications
floooh Jun 2, 2018
4bc0d52
remove mentioning of VS2013 from BUILD.md
floooh Jun 9, 2018
512e3be
temp comment out the unittests in cmake files
floooh Mar 6, 2019
3bc70a4
resume working on sokol_gfx.h integration
floooh Mar 6, 2019
c3467ef
Gfx: split ApplyDrawState into ApplyPipeline and ApplyBindings
floooh Mar 7, 2019
e53ea21
Dbg: fixes for Gfx API updates
floooh Mar 7, 2019
b8c22d4
Start fixing samples for Gfx API changes
floooh Mar 7, 2019
d5300dd
rewrite Gfx structs initialization yet again
floooh Mar 8, 2019
8a1c47b
Assets, Dbg, Shader.py: fixes for Gfx API changes
floooh Mar 8, 2019
5ae95f7
Converted more samples
floooh Mar 9, 2019
a5217fb
fixed all samples
floooh Mar 12, 2019
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
16 changes: 1 addition & 15 deletions code/Modules/Assets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,10 @@ fips_begin_module(Assets)
fips_vs_warning_level(3)
fips_dir(Gfx)
fips_files(
FullscreenQuadBuilder.cc FullscreenQuadBuilder.h
MeshBuilder.cc MeshBuilder.h
ShapeBuilder.cc ShapeBuilder.h
VertexWriter.cc VertexWriter.h
TextureLoader.cc TextureLoader.h
OmshParser.cc OmshParser.h
MeshLoader.cc MeshLoader.h
)
fips_end_module()

fips_begin_unittest(Assets)
fips_vs_warning_level(3)
fips_dir(UnitTests)
fips_files(
MeshBuilderTest.cc
ShapeBuilderTest.cc
VertexWriterTest.cc
)
fips_deps(Gfx Assets)
fips_end_unittest()


41 changes: 41 additions & 0 deletions code/Modules/Assets/Gfx/FullscreenQuadBuilder.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//------------------------------------------------------------------------------
// FullscreenQuadBuilder.cc
//------------------------------------------------------------------------------
#include "Pre.h"
#include "FullscreenQuadBuilder.h"

namespace Oryol {

static const float vertsNoFlip[20] = {
-1.0f, +1.0f, 0.0f, 0.0f, 1.0f,
+1.0f, +1.0f, 0.0f, 1.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
+1.0f, -1.0f, 0.0f, 1.0f, 0.0f
};

static const float vertsFlip[20] = {
-1.0f, +1.0f, 0.0f, 0.0f, 0.0f,
+1.0f, +1.0f, 0.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f, 1.0f,
+1.0f, -1.0f, 0.0f, 1.0f, 1.0f
};

static_assert(sizeof(vertsNoFlip) == sizeof(vertsFlip), "FullscreenQuadBuilder");

FullscreenQuadBuilder::Result
FullscreenQuadBuilder::Build() {
Result res;
res.VertexBufferDesc
.SetType(BufferType::VertexBuffer)
.SetSize(sizeof(vertsNoFlip))
.SetContent(this->flipV ? vertsFlip : vertsNoFlip);
res.PipelineDesc
.SetLayout(0, {
{ "position", VertexFormat::Float3 },
{ "texcoord0", VertexFormat::Float2 }
})
.SetPrimitiveType(PrimitiveType::TriangleStrip);
return res;
}

} // namespace Oryol
49 changes: 49 additions & 0 deletions code/Modules/Assets/Gfx/FullscreenQuadBuilder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once
//------------------------------------------------------------------------------
/**
@class Oryol::FullscreenQuadBuilder
@ingroup Assets
@brief helper class to build a fullscreen quad mesh.

FIXME: probably makes sense to rewrite this to a single triangle

Positions (vertex attr name: "position")
0: -1.0,+1.0,0.0
1: +1.0,+1.0,0.0
2: -1.0,-1.0,0.0
3: +1.0,-1.0,0.0

UV Coords (vertex attr name: "texcoord0", FlipV == false:
0: 0.0, 1.0
1: 1.0, 1.0
2: 0.0, 0.0
3: 1.0, 0.0

UV Coords, FlipV == true:
0: 0.0, 0.0
1: 1.0, 0.0
2: 0.0, 1.0
3: 1.0, 1.0
*/
#include "Gfx/GfxTypes.h"

namespace Oryol {

class FullscreenQuadBuilder {
public:
struct Result {
BufferDesc VertexBufferDesc;
struct PipelineDesc PipelineDesc; // blueprint pipeline desc
int NumElements = 4; // rendered as triangle strip
};
bool flipV = false;

// texture v coord is (1.0 - y)
FullscreenQuadBuilder& FlipV(bool b) { flipV = b; return *this; }
bool FlipV() const { return flipV; }

// populate and return Result object
Result Build();
};

} // namespace Oryol
83 changes: 37 additions & 46 deletions code/Modules/Assets/Gfx/MeshBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,55 @@
#include "Pre.h"
#include "MeshBuilder.h"
#include "Core/Assertion.h"
#include <cstring>

namespace Oryol {

//------------------------------------------------------------------------------
MeshBuilder&
MeshBuilder::Begin() {
o_assert(!this->inBegin);
o_assert(this->NumVertices > 0);
o_assert(!this->Layout.Empty());
this->inBegin = true;

// setup MeshSetup object
MeshSetup& meshSetup = this->setupAndData.Setup;
meshSetup = MeshSetup::FromData(this->VertexUsage, this->IndexUsage);
meshSetup.Layout = this->Layout;
meshSetup.NumVertices = this->NumVertices;
meshSetup.NumIndices = this->NumIndices;
meshSetup.IndicesType = this->IndicesType;
for (const auto& primGroup : this->PrimitiveGroups) {
meshSetup.AddPrimitiveGroup(primGroup);
}

// compute the required stream size
const int vbSize = Memory::RoundUp(this->NumVertices * this->Layout.ByteSize(), 4);
const int ibSize = this->NumIndices * IndexType::ByteSize(this->IndicesType);
MeshBuilder::Result
MeshBuilder::Build(std::function<void(MeshBuilder& mb)> func) {
o_assert_dbg(!this->inBuild);
o_assert_dbg(this->numVertices > 0);
o_assert_dbg(!this->layout.Empty());
this->inBuild = true;

// compute the data buffer size
const int vbSize = this->numVertices * this->layout.ByteSize();
const int ibSize = this->numIndices * IndexType::ByteSize(this->indexType);
int allSize = vbSize + ibSize;
meshSetup.VertexDataOffset = 0;
if (ibSize > 0) {
meshSetup.IndexDataOffset = vbSize;
}


// setup the data buffer object
this->vertexPointer = this->setupAndData.Data.Add(allSize);
this->vertexPointer = (uint8_t*) Memory::Alloc(allSize);
this->indexPointer = this->vertexPointer + vbSize;
this->endPointer = this->indexPointer + ibSize;

return *this;
}

//------------------------------------------------------------------------------
SetupAndData<MeshSetup>
MeshBuilder::Build() {
o_assert(this->inBegin);

this->inBegin = false;

// NOTE: explicit moves required by VS2013
SetupAndData<MeshSetup> result(std::move(this->setupAndData));

// clear private data, not configuration data
// call the content-build function
func(*this);

// setup the Result object
Result res;
res.Data.MoveRaw(this->vertexPointer, allSize);
res.Layout = this->layout;
res.IndexType = this->indexType;
res.VertexBufferDesc = BufferDesc()
.SetSize(vbSize)
.SetType(BufferType::VertexBuffer)
.SetUsage(this->vertexUsage)
.SetContent(this->vertexPointer);
if (ibSize > 0) {
res.IndexBufferDesc = BufferDesc()
.SetSize(ibSize)
.SetType(BufferType::IndexBuffer)
.SetUsage(this->indexUsage)
.SetContent(this->indexPointer);
}
else {
res.IndexBufferDesc = BufferDesc();
}
this->inBuild = false;
this->vertexPointer = nullptr;
this->indexPointer = nullptr;
this->endPointer = nullptr;
this->setupAndData.Setup = MeshSetup::FromData();
this->setupAndData.Data.Clear();

return result;
return res;
}

} // namespace Oryol
Loading