mirror of https://github.com/xemu-project/xemu.git
nv2a/vk: Clean up layout binding ids
This commit is contained in:
parent
adbbcfff1f
commit
4010cba32e
|
@ -762,9 +762,11 @@ static MString* psh_convert(struct PixelShader *ps)
|
|||
ps->state.smooth_shading, true, false, false);
|
||||
|
||||
if (ps->opts.vulkan) {
|
||||
mstring_append_fmt(preflight,
|
||||
"layout(location = 0) out vec4 fragColor;\n"
|
||||
"layout(binding = %d, std140) uniform PshUniforms {\n", PSH_UBO_BINDING);
|
||||
mstring_append_fmt(
|
||||
preflight,
|
||||
"layout(location = 0) out vec4 fragColor;\n"
|
||||
"layout(binding = %d, std140) uniform PshUniforms {\n",
|
||||
ps->opts.ubo_binding);
|
||||
} else {
|
||||
mstring_append_fmt(preflight,
|
||||
"layout(location = 0) out vec4 fragColor;\n");
|
||||
|
@ -1201,7 +1203,7 @@ static MString* psh_convert(struct PixelShader *ps)
|
|||
|
||||
if (sampler_type != NULL) {
|
||||
if (ps->opts.vulkan) {
|
||||
mstring_append_fmt(preflight, "layout(binding = %d) ", PSH_TEX_BINDING + i);
|
||||
mstring_append_fmt(preflight, "layout(binding = %d) ", ps->opts.tex_binding + i);
|
||||
}
|
||||
mstring_append_fmt(preflight, "uniform %s texSamp%d;\n", sampler_type, i);
|
||||
|
||||
|
|
|
@ -32,12 +32,10 @@
|
|||
#include "qemu/mstring.h"
|
||||
#include "hw/xbox/nv2a/pgraph/psh.h"
|
||||
|
||||
// FIXME: Move to struct
|
||||
#define PSH_UBO_BINDING 1
|
||||
#define PSH_TEX_BINDING 2
|
||||
|
||||
typedef struct GenPshGlslOptions {
|
||||
bool vulkan;
|
||||
int ubo_binding;
|
||||
int tex_binding;
|
||||
} GenPshGlslOptions;
|
||||
|
||||
MString *pgraph_gen_psh_glsl(const PshState state, GenPshGlslOptions opts);
|
||||
|
|
|
@ -310,7 +310,7 @@ MString *pgraph_gen_vsh_glsl(const VshState *state,
|
|||
"layout(binding = %d, std140) uniform VshUniforms {\n"
|
||||
"%s"
|
||||
"};\n\n",
|
||||
VSH_UBO_BINDING, mstring_get_str(uniforms));
|
||||
opts.ubo_binding, mstring_get_str(uniforms));
|
||||
} else {
|
||||
mstring_append(
|
||||
output, mstring_get_str(uniforms));
|
||||
|
|
|
@ -25,13 +25,11 @@
|
|||
#include "qemu/mstring.h"
|
||||
#include "hw/xbox/nv2a/pgraph/vsh.h"
|
||||
|
||||
// FIXME: Move to struct
|
||||
#define VSH_UBO_BINDING 0
|
||||
|
||||
typedef struct GenVshGlslOptions {
|
||||
bool vulkan;
|
||||
bool prefix_outputs;
|
||||
bool use_push_constants_for_uniform_attrs;
|
||||
int ubo_binding;
|
||||
} GenVshGlslOptions;
|
||||
|
||||
MString *pgraph_gen_vsh_glsl(const VshState *state,
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
#include "renderer.h"
|
||||
#include <locale.h>
|
||||
|
||||
#define VSH_UBO_BINDING 0
|
||||
#define PSH_UBO_BINDING 1
|
||||
#define PSH_TEX_BINDING 2
|
||||
|
||||
const size_t MAX_UNIFORM_ATTR_VALUES_SIZE = NV2A_VERTEXSHADER_ATTRIBUTES * 4 * sizeof(float);
|
||||
|
||||
static void create_descriptor_pool(PGRAPHState *pg)
|
||||
|
@ -428,6 +432,7 @@ static ShaderBinding *gen_shaders(PGRAPHState *pg, ShaderState *state)
|
|||
.prefix_outputs = geometry_shader_code != NULL,
|
||||
.use_push_constants_for_uniform_attrs =
|
||||
r->use_push_constants_for_uniform_attrs,
|
||||
.ubo_binding = VSH_UBO_BINDING,
|
||||
});
|
||||
NV2A_VK_DPRINTF("vertex shader: \n%s",
|
||||
mstring_get_str(vertex_shader_code));
|
||||
|
@ -437,7 +442,11 @@ static ShaderBinding *gen_shaders(PGRAPHState *pg, ShaderState *state)
|
|||
mstring_unref(vertex_shader_code);
|
||||
|
||||
MString *fragment_shader_code = pgraph_gen_psh_glsl(
|
||||
state->psh, (GenPshGlslOptions){ .vulkan = true });
|
||||
state->psh, (GenPshGlslOptions){
|
||||
.vulkan = true,
|
||||
.ubo_binding = PSH_UBO_BINDING,
|
||||
.tex_binding = PSH_TEX_BINDING,
|
||||
});
|
||||
NV2A_VK_DPRINTF("fragment shader: \n%s",
|
||||
mstring_get_str(fragment_shader_code));
|
||||
snode->fragment = pgraph_vk_create_shader_module_from_glsl(
|
||||
|
|
Loading…
Reference in New Issue