nv2a: Support integer scaling of surface dimensions

This commit is contained in:
Matt Borgerson
2021-07-20 10:37:07 -07:00
committed by mborgerson
parent 814d7e0a9a
commit 5562a484e1
7 changed files with 457 additions and 151 deletions
+1
View File
@@ -117,6 +117,7 @@ void gl_debug_frame_terminator(void);
_X(NV2A_PROF_SURF_DOWNLOAD) \
_X(NV2A_PROF_SURF_UPLOAD) \
_X(NV2A_PROF_SURF_TO_TEX) \
_X(NV2A_PROF_SURF_TO_TEX_FALLBACK) \
enum NV2A_PROF_COUNTERS_ENUM {
#define _X(x) x,
+2
View File
@@ -24,5 +24,7 @@
void nv2a_init(PCIBus *bus, int devfn, MemoryRegion *ram);
void nv2a_gl_context_init(void);
int nv2a_get_framebuffer_surface(void);
void nv2a_set_surface_scale_factor(unsigned int scale);
unsigned int nv2a_get_surface_scale_factor(void);
#endif
+3
View File
@@ -172,6 +172,7 @@ typedef struct TextureBinding {
unsigned int refcnt;
int draw_time;
uint64_t data_hash;
unsigned int scale;
} TextureBinding;
typedef struct TextureKey {
@@ -370,6 +371,8 @@ typedef struct PGRAPHState {
bool flush_pending;
bool gl_sync_pending;
QemuEvent gl_sync_complete;
unsigned int surface_scale_factor;
uint8_t *scale_buf;
} PGRAPHState;
typedef struct NV2AState {
+437 -145
View File
File diff suppressed because it is too large Load Diff
+8 -6
View File
@@ -686,6 +686,7 @@ static MString* psh_convert(struct PixelShader *ps)
NV2A_UNIMPLEMENTED("Convolution for 2D textures");
}
}
mstring_append_fmt(vars, "pT%d.xy = texScale%d * pT%d.xy;\n", i, i, i);
mstring_append_fmt(vars, "vec4 t%d = %s(texSamp%d, pT%d.xyw);\n",
i, lookup, i, i);
break;
@@ -732,8 +733,8 @@ static MString* psh_convert(struct PixelShader *ps)
/* FIXME: Do bumpMat swizzle on CPU before upload */
mstring_append_fmt(vars, "dsdt%d = mat2(bumpMat%d[0].xy, bumpMat%d[1].yx) * dsdt%d;\n",
i, i, i, i);
mstring_append_fmt(vars, "vec4 t%d = texture(texSamp%d, pT%d.xy + dsdt%d);\n",
i, i, i, i);
mstring_append_fmt(vars, "vec4 t%d = texture(texSamp%d, texScale%d * (pT%d.xy + dsdt%d));\n",
i, i, i, i, i);
break;
case PS_TEXTUREMODES_BUMPENVMAP_LUM:
assert(i >= 1);
@@ -755,8 +756,8 @@ static MString* psh_convert(struct PixelShader *ps)
/* FIXME: Do bumpMat swizzle on CPU before upload */
mstring_append_fmt(vars, "dsdtl%d.st = mat2(bumpMat%d[0].xy, bumpMat%d[1].yx) * dsdtl%d.st;\n",
i, i, i, i);
mstring_append_fmt(vars, "vec4 t%d = texture(texSamp%d, pT%d.xy + dsdtl%d.st);\n",
i, i, i, i);
mstring_append_fmt(vars, "vec4 t%d = texture(texSamp%d, texScale%d * (pT%d.xy + dsdtl%d.st));\n",
i, i, i, i, i);
mstring_append_fmt(vars, "t%d = t%d * (bumpScale%d * dsdtl%d.p + bumpOffset%d);\n",
i, i, i, i, i);
break;
@@ -772,8 +773,8 @@ static MString* psh_convert(struct PixelShader *ps)
mstring_append_fmt(vars, "/* PS_TEXTUREMODES_DOT_ST */\n");
mstring_append_fmt(vars, "float dot%d = dot(pT%d.xyz, %s(t%d.rgb));\n",
i, i, dotmap_func, ps->input_tex[i]);
mstring_append_fmt(vars, "vec4 t%d = texture(texSamp%d, vec2(dot%d, dot%d));\n",
i, i, i-1, i);
mstring_append_fmt(vars, "vec4 t%d = texture(texSamp%d, texScale%d * vec2(dot%d, dot%d));\n",
i, i, i, i-1, i);
break;
case PS_TEXTUREMODES_DOT_ZW:
assert(i >= 2);
@@ -863,6 +864,7 @@ static MString* psh_convert(struct PixelShader *ps)
break;
}
mstring_append_fmt(preflight, "uniform float texScale%d;\n", i);
if (sampler_type != NULL) {
mstring_append_fmt(preflight, "uniform %s texSamp%d;\n", sampler_type, i);
+5
View File
@@ -1001,6 +1001,11 @@ ShaderBinding* generate_shaders(const ShaderState state)
ret->bump_offset_loc[i] = glGetUniformLocation(program, tmp);
}
for (int i = 0; i < NV2A_MAX_TEXTURES; i++) {
snprintf(tmp, sizeof(tmp), "texScale%d", i);
ret->tex_scale_loc[i] = glGetUniformLocation(program, tmp);
}
/* lookup vertex shader uniforms */
for(i = 0; i < NV2A_VERTEXSHADER_CONSTANTS; i++) {
snprintf(tmp, sizeof(tmp), "c[%d]", i);
+1
View File
@@ -105,6 +105,7 @@ typedef struct ShaderBinding {
GLint bump_mat_loc[NV2A_MAX_TEXTURES];
GLint bump_scale_loc[NV2A_MAX_TEXTURES];
GLint bump_offset_loc[NV2A_MAX_TEXTURES];
GLint tex_scale_loc[NV2A_MAX_TEXTURES];
GLint surface_size_loc;
GLint clip_range_loc;