Rtt menu options are now handled by GLES

This commit is contained in:
Marcel Szewczyk 2018-11-11 20:51:05 +01:00
parent 4fd9de54ce
commit 5f19eb7ae8
7 changed files with 103 additions and 40 deletions

View File

@ -147,7 +147,7 @@ bool QueueRender(TA_context* ctx)
bool too_fast = (cycle_span / time_span) > (SH4_MAIN_CLOCK * 1.2);
if ((rqueue && too_fast && settings.pvr.SynchronousRender) ||
(rqueue && ctx->rend.isRTT)) {
(settings.dreamcast.rttOption != 0 && rqueue && ctx->rend.isRTT)) {
//wait for a frame if
// we have another one queue'd and
// sh4 run at > 120% on the last slice

View File

@ -146,18 +146,18 @@ s32 SetTileClip(u32 val, bool set)
return 0;
if (set && clip_mode) {
if (!pvrrc.isRTT) {
float t = cey;
cey = 480 - csy;
csy = 480 - t;
float dc2s_scale_h = screen_height / 480.0f;
float ds2s_offs_x = (screen_width - dc2s_scale_h * 640) / 2;
csx = csx * dc2s_scale_h + ds2s_offs_x;
cex = cex * dc2s_scale_h + ds2s_offs_x;
csy = csy * dc2s_scale_h;
cey = cey * dc2s_scale_h;
}
glUniform4f(CurrentShader->pp_ClipTest, csx, csy, cex, cey);
if (!pvrrc.isRTT) {
float t = cey;
cey = 480 - csy;
csy = 480 - t;
float dc2s_scale_h = screen_height / 480.0f;
float ds2s_offs_x = (screen_width - dc2s_scale_h * 640) / 2;
csx = csx * dc2s_scale_h + ds2s_offs_x;
cex = cex * dc2s_scale_h + ds2s_offs_x;
csy = csy * dc2s_scale_h;
cey = cey * dc2s_scale_h;
}
glUniform4f(CurrentShader->pp_ClipTest, csx, csy, cex, cey);
}
return clip_mode;

View File

@ -997,6 +997,8 @@ bool gles_init()
if (!gl_create_resources())
return false;
InitShadowCircle();
#if defined(GLES) && HOST_OS != OS_DARWIN && !defined(TARGET_NACL32)
#ifdef TARGET_PANDORA
fbdev=open("/dev/fb0", O_RDONLY);
@ -1448,6 +1450,11 @@ void OSD_DRAW()
bool ProcessFrame(TA_context* ctx)
{
if (ctx->rend.isRTT && settings.dreamcast.rttOption == 0)
{
return false;
}
ctx->rend_inuse.Lock();
ctx->MarkRend();
@ -1780,8 +1787,6 @@ bool RenderFrame()
#endif
}
printf("RTT option: %d", settings.dreamcast.rttOption);
//Clear depth
//Color is cleared by the bgp
if (settings.rend.WideScreen)
@ -1839,7 +1844,10 @@ bool RenderFrame()
//restore scale_x
scale_x /= scissoring_scale_x;
DrawStrips();
if (!(is_rtt && (settings.dreamcast.rttOption > 0 && settings.dreamcast.rttOption <= 3)))
{
DrawStrips();
}
#if HOST_OS==OS_WINDOWS
//Sleep(40); //to test MT stability

View File

@ -122,6 +122,7 @@ void FreeRTTBuffers();
int GetProgramID(u32 cp_AlphaTest, u32 pp_ClipTestMode,
u32 pp_Texture, u32 pp_UseAlpha, u32 pp_IgnoreTexA, u32 pp_ShadInstr, u32 pp_Offset,
u32 pp_FogCtrl);
void InitShadowCircle();
bool CompilePipelineShader(PipelineShader* s);
#define TEXTURE_LOAD_ERROR 0

View File

@ -1,6 +1,7 @@
#include "gles.h"
#include "rend/TexCache.h"
#include "hw/pvr/pvr_mem.h"
#include <math.h>
/*
Textures
@ -20,6 +21,9 @@ Compression
look into it, but afaik PVRC is not realtime doable
*/
const u32 shadowCircleW = 128;
const u32 shadowCircleH = 128;
u16 shadowCircleTexture[shadowCircleW][shadowCircleH] = {0};
u16 buf[1024*1024];
#if FEAT_HAS_SOFTREND
@ -445,26 +449,16 @@ void BindRTT(u32 addy, u32 fbw, u32 fbh, u32 channels, u32 fmt)
glViewport(0, 0, fbw, fbh);
}
void ReadRTT() {
FBT& rv=fb_rtt;
//get viewport width and height from rtt framebuffer
GLint dimensions[4] = {0};
glGetIntegerv(GL_VIEWPORT, dimensions);
GLint w = dimensions[2];
GLint h = dimensions[3];
//bind texture to which we have rendered in the last rtt pass
glBindTexture(GL_TEXTURE_2D, rv.tex);
switch(FB_W_CTRL.fb_packmode)
{
void handlePackModeRTT(GLint w, GLint h)
{
switch (FB_W_CTRL.fb_packmode) {
//currently RGB 565 is supported only
case 1: //0x1 565 RGB 16 bit
{
u16 *dataPointer = temp_tex_buffer;
u16 *dataPointer = temp_tex_buffer;
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, temp_tex_buffer);
for (u32 i = 0; i < w * h; i++) {
for (u32 i = 0; i < w * h; i++)
{
buf[i] = ((*dataPointer & 0xF000) >> 12) | ((*dataPointer & 0x0FFF) << 4);
*dataPointer++;
}
@ -481,7 +475,46 @@ void ReadRTT() {
}
}
void FreeRTTBuffers() {
void ReadRTT()
{
FBT& rv=fb_rtt;
//get viewport width and height from rtt framebuffer
GLint dimensions[4] = {0};
glGetIntegerv(GL_VIEWPORT, dimensions);
GLint w = dimensions[2];
GLint h = dimensions[3];
//bind texture to which we have rendered in the last rtt pass
glBindTexture(GL_TEXTURE_2D, rv.tex);
if (settings.dreamcast.rttOption == 3)
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shadowCircleW, shadowCircleH, 0,
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, shadowCircleTexture[0]);
}
else if (settings.dreamcast.rttOption == 2)
{
for (u32 i = 0; i < w * h; i++)
buf[i] = ~0;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, buf);
}
else if (settings.dreamcast.rttOption == 1)
{
for (u32 i = 0; i < w * h; i++)
buf[i] = 0;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, buf);
}
else if (settings.dreamcast.rttOption == 4)
{
handlePackModeRTT(w, h);
}
}
void FreeRTTBuffers()
{
if (fb_rtt.fbo) { glDeleteFramebuffers(1,&fb_rtt.fbo); fb_rtt.fbo = 0; }
if (fb_rtt.tex) { glDeleteTextures(1,&fb_rtt.tex); fb_rtt.tex = 0; }
if (fb_rtt.depthb) { glDeleteRenderbuffers(1,&fb_rtt.depthb); fb_rtt.depthb = 0; }
@ -568,12 +601,12 @@ text_info raw_GetTexture(TSP tsp, TCW tcw)
//return gl texture
rv.height = tf->h;
rv.width = tf->w;
rv.pdata = tf->pData;
rv.textype = tf->tex_type;
rv.width = tf->w;
rv.pdata = tf->pData;
rv.textype = tf->tex_type;
return rv;
return rv;
}
void CollectCleanup() {
@ -602,6 +635,30 @@ void CollectCleanup() {
void DoCleanup() {
}
void InitShadowCircle() {
s32 middle_x = shadowCircleW / 2;
s32 middle_y = shadowCircleH / 2;
u32 radius = 15;
s32 x = 0, y = 0;
for (s32 i = 0; i <= 360; i = i + 2) {
x = s32(radius * cos(i * M_PI / 180));
y = s32(radius * sin(i * M_PI / 180));
shadowCircleTexture[middle_x + x][middle_y + y] = 0x5555;
if (y < 0) {
for (s32 j = 0; j < abs(y); ++j) {
shadowCircleTexture[middle_x + x][middle_y - j] = 0xAAAA;
}
} else {
for (s32 j = 1; j < y; ++j) {
shadowCircleTexture[middle_x + x][middle_y + j] = 0xAAAA;
}
}
}
}
void killtex()
{
for (TexCacheIter i=TexCache.begin();i!=TexCache.end();i++)

View File

@ -378,7 +378,6 @@ public class OptionsFragment extends Fragment {
}
});
//----------------------------------------
String[] rtts = getResources().getStringArray(R.array.rtt);
Spinner rtt_spnr = (Spinner) getView().findViewById(R.id.rtt_spinner);
ArrayAdapter<String> rttAdapter = new ArrayAdapter<>(
@ -394,7 +393,6 @@ public class OptionsFragment extends Fragment {
public void onNothingSelected(AdapterView<?> arg0) {
}
});
//----------------------------------------
OnCheckedChangeListener limitfps_option = new OnCheckedChangeListener() {

View File

@ -108,7 +108,6 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rtt(JNIEnv *env,jobje
settings.dreamcast.rttOption = rtt;
}
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_limitfps(JNIEnv *env,jobject obj, jint limiter)
{
settings.aica.LimitFPS = limiter;