libretro-samples/video/opengl/libretro_test_gl_compute_shaders
Emery Hemingway fd6547e86f Tupfiles for super-repositories
Add minimal metadata for a Tup build system. Tup will discover any file
named "Tupfile" in a the sub-directories where it is run. In this case a
tupfile defines the core name and invokes the "include_rules" directive,
which will include the Tup rules defined in parent directories. This
allows a parent repository with platform-specific build rules to host
this repository as a submodule. The sample cores may thus be ported to
new platforms without polluting the local makefiles. Naturally the
external build rules must be synchronized with the source code herein,
the tupfiles here only define TARGET_NAME so that they will never
contradict information contained in the makefiles.

A sample Tuprules.tup for a super-repository:

ifeq ($(TARGET_NAME),advanced_tests)
	CFLAGS += -I../../libretro-common/include
	SOURCES_C += libretro-test.c
endif
CFLAGS += -O3 -Wall -pedantic -std=gnu99
: foreach $(SOURCES_C) |> !libretro_cc |> {objs}
: {objs} |> !libretro_ld |> $(TARGET_NAME)_libretro.so
2019-03-03 12:34:32 +01:00
..
app Report a zero audio sample rate for silent cores 2019-03-03 11:51:09 +01:00
gl Rename graphics to video 2016-10-07 15:23:54 +02:00
glm Rename graphics to video 2016-10-07 15:23:54 +02:00
glsym Rename graphics to video 2016-10-07 15:23:54 +02:00
libretro Rename graphics to video 2016-10-07 15:23:54 +02:00
rpng Rename graphics to video 2016-10-07 15:23:54 +02:00
link.T Rename graphics to video 2016-10-07 15:23:54 +02:00
Makefile Rename graphics to video 2016-10-07 15:23:54 +02:00
README.md Rename graphics to video 2016-10-07 15:23:54 +02:00
Tupfile Tupfiles for super-repositories 2019-03-03 12:34:32 +01:00

libretro_test_gl_compute_shaders

This sample demonstrates a compute shader graphics demo using OpenGL 4.3. It uses tons of instanced geometry, and targets libretro GL as a backend.

Purpose of the compute shader is to do frustum culling, LOD-sorting and some simple physics for fun.

After compute shader, indirect drawing is used to draw instanced geometry. The indirect drawing buffer is updated with atomic counters from compute shader.

The LOD-sorting allows us to instance few but complex meshes when we're close, and progressively less and less detail per instance. Last LOD is just point sprites.

The number of blocks in play is ~850k. With an nVidia GTX760, performance is roughly 300-500 FPS up to 1000 FPS depending on the scene complexity after culling.

LOD0: Blender monkey (Suzanne) (diffuse + specular lighting)
LOD1: Cube (diffuse lighting)
LOD2: Point sprites

Video

YouTube

Requirements

A graphics card driver supporting OpenGL 4.3 and/or higher.

Programming language

C++11

Building

To compile, you will need a C++11 compiler and assorted toolchain installed.

make

This targets libretro GL interface, so you need a libretro frontend supporting this interface, such as RetroArch, installed.

Running

After building, this command should run the program:

retroarch -L boxes_libretro.so