libobs: Full-screen triangle format conversions

The cache coherency of rasterization for full-screen passes is better
using an oversized triangle that is clipped rather than two triangles.
Traversal order of rasterization is GPU-specific, but will almost
certainly be better using an undivided primitive.

A smaller benefit is that quads along the diagonal are not evaluated
multiple times, but that's minor in comparison.

Redo format shaders to bypass vertex buffer, and input layout. Add
global shader bool "obs_glsl_compile" to make API-specific decisions,
i.e. handle upside-down UVs. gl_ortho is not needed for format
conversion because the vertex shader does not use ViewProj anymore.

This can be applied to more situations, but start small first.

Testbed full screen passes, Intel HD Graphics 530:
RGBA -> UYVX: 467 -> 439 us, ~6% savings
UYVX -> uv: 295 -> 239 us, ~19% savings
This commit is contained in:
James Park
2019-06-02 06:49:38 -07:00
committed by jp9000
parent 6a795d52ea
commit aa22b61e3e
9 changed files with 67 additions and 44 deletions

View File

@@ -891,7 +891,7 @@ void device_begin_scene(gs_device_t *device)
clear_textures(device);
}
static inline bool can_render(const gs_device_t *device)
static inline bool can_render(const gs_device_t *device, uint32_t num_verts)
{
if (!device->cur_vertex_shader) {
blog(LOG_ERROR, "No vertex shader specified");
@@ -903,7 +903,7 @@ static inline bool can_render(const gs_device_t *device)
return false;
}
if (!device->cur_vertex_buffer) {
if (!device->cur_vertex_buffer && (num_verts == 0)) {
blog(LOG_ERROR, "No vertex buffer specified");
return false;
}
@@ -977,7 +977,7 @@ void device_draw(gs_device_t *device, enum gs_draw_mode draw_mode,
gs_effect_t *effect = gs_get_effect();
struct gs_program *program;
if (!can_render(device))
if (!can_render(device, num_verts))
goto fail;
if (effect)