Rtt menu options are now handled by GLES
This commit is contained in:
parent
4fd9de54ce
commit
5f19eb7ae8
|
@ -147,7 +147,7 @@ bool QueueRender(TA_context* ctx)
|
||||||
bool too_fast = (cycle_span / time_span) > (SH4_MAIN_CLOCK * 1.2);
|
bool too_fast = (cycle_span / time_span) > (SH4_MAIN_CLOCK * 1.2);
|
||||||
|
|
||||||
if ((rqueue && too_fast && settings.pvr.SynchronousRender) ||
|
if ((rqueue && too_fast && settings.pvr.SynchronousRender) ||
|
||||||
(rqueue && ctx->rend.isRTT)) {
|
(settings.dreamcast.rttOption != 0 && rqueue && ctx->rend.isRTT)) {
|
||||||
//wait for a frame if
|
//wait for a frame if
|
||||||
// we have another one queue'd and
|
// we have another one queue'd and
|
||||||
// sh4 run at > 120% on the last slice
|
// sh4 run at > 120% on the last slice
|
||||||
|
|
|
@ -146,18 +146,18 @@ s32 SetTileClip(u32 val, bool set)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (set && clip_mode) {
|
if (set && clip_mode) {
|
||||||
if (!pvrrc.isRTT) {
|
if (!pvrrc.isRTT) {
|
||||||
float t = cey;
|
float t = cey;
|
||||||
cey = 480 - csy;
|
cey = 480 - csy;
|
||||||
csy = 480 - t;
|
csy = 480 - t;
|
||||||
float dc2s_scale_h = screen_height / 480.0f;
|
float dc2s_scale_h = screen_height / 480.0f;
|
||||||
float ds2s_offs_x = (screen_width - dc2s_scale_h * 640) / 2;
|
float ds2s_offs_x = (screen_width - dc2s_scale_h * 640) / 2;
|
||||||
csx = csx * dc2s_scale_h + ds2s_offs_x;
|
csx = csx * dc2s_scale_h + ds2s_offs_x;
|
||||||
cex = cex * dc2s_scale_h + ds2s_offs_x;
|
cex = cex * dc2s_scale_h + ds2s_offs_x;
|
||||||
csy = csy * dc2s_scale_h;
|
csy = csy * dc2s_scale_h;
|
||||||
cey = cey * dc2s_scale_h;
|
cey = cey * dc2s_scale_h;
|
||||||
}
|
}
|
||||||
glUniform4f(CurrentShader->pp_ClipTest, csx, csy, cex, cey);
|
glUniform4f(CurrentShader->pp_ClipTest, csx, csy, cex, cey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return clip_mode;
|
return clip_mode;
|
||||||
|
|
|
@ -997,6 +997,8 @@ bool gles_init()
|
||||||
if (!gl_create_resources())
|
if (!gl_create_resources())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
InitShadowCircle();
|
||||||
|
|
||||||
#if defined(GLES) && HOST_OS != OS_DARWIN && !defined(TARGET_NACL32)
|
#if defined(GLES) && HOST_OS != OS_DARWIN && !defined(TARGET_NACL32)
|
||||||
#ifdef TARGET_PANDORA
|
#ifdef TARGET_PANDORA
|
||||||
fbdev=open("/dev/fb0", O_RDONLY);
|
fbdev=open("/dev/fb0", O_RDONLY);
|
||||||
|
@ -1448,6 +1450,11 @@ void OSD_DRAW()
|
||||||
|
|
||||||
bool ProcessFrame(TA_context* ctx)
|
bool ProcessFrame(TA_context* ctx)
|
||||||
{
|
{
|
||||||
|
if (ctx->rend.isRTT && settings.dreamcast.rttOption == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->rend_inuse.Lock();
|
ctx->rend_inuse.Lock();
|
||||||
ctx->MarkRend();
|
ctx->MarkRend();
|
||||||
|
|
||||||
|
@ -1780,8 +1787,6 @@ bool RenderFrame()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("RTT option: %d", settings.dreamcast.rttOption);
|
|
||||||
|
|
||||||
//Clear depth
|
//Clear depth
|
||||||
//Color is cleared by the bgp
|
//Color is cleared by the bgp
|
||||||
if (settings.rend.WideScreen)
|
if (settings.rend.WideScreen)
|
||||||
|
@ -1839,7 +1844,10 @@ bool RenderFrame()
|
||||||
//restore scale_x
|
//restore scale_x
|
||||||
scale_x /= scissoring_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
|
#if HOST_OS==OS_WINDOWS
|
||||||
//Sleep(40); //to test MT stability
|
//Sleep(40); //to test MT stability
|
||||||
|
|
|
@ -122,6 +122,7 @@ void FreeRTTBuffers();
|
||||||
int GetProgramID(u32 cp_AlphaTest, u32 pp_ClipTestMode,
|
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_Texture, u32 pp_UseAlpha, u32 pp_IgnoreTexA, u32 pp_ShadInstr, u32 pp_Offset,
|
||||||
u32 pp_FogCtrl);
|
u32 pp_FogCtrl);
|
||||||
|
void InitShadowCircle();
|
||||||
|
|
||||||
bool CompilePipelineShader(PipelineShader* s);
|
bool CompilePipelineShader(PipelineShader* s);
|
||||||
#define TEXTURE_LOAD_ERROR 0
|
#define TEXTURE_LOAD_ERROR 0
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "gles.h"
|
#include "gles.h"
|
||||||
#include "rend/TexCache.h"
|
#include "rend/TexCache.h"
|
||||||
#include "hw/pvr/pvr_mem.h"
|
#include "hw/pvr/pvr_mem.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Textures
|
Textures
|
||||||
|
@ -20,6 +21,9 @@ Compression
|
||||||
look into it, but afaik PVRC is not realtime doable
|
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];
|
u16 buf[1024*1024];
|
||||||
|
|
||||||
#if FEAT_HAS_SOFTREND
|
#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);
|
glViewport(0, 0, fbw, fbh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadRTT() {
|
void handlePackModeRTT(GLint w, GLint h)
|
||||||
FBT& rv=fb_rtt;
|
{
|
||||||
|
switch (FB_W_CTRL.fb_packmode) {
|
||||||
//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)
|
|
||||||
{
|
|
||||||
//currently RGB 565 is supported only
|
//currently RGB 565 is supported only
|
||||||
case 1: //0x1 565 RGB 16 bit
|
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);
|
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);
|
buf[i] = ((*dataPointer & 0xF000) >> 12) | ((*dataPointer & 0x0FFF) << 4);
|
||||||
*dataPointer++;
|
*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.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.tex) { glDeleteTextures(1,&fb_rtt.tex); fb_rtt.tex = 0; }
|
||||||
if (fb_rtt.depthb) { glDeleteRenderbuffers(1,&fb_rtt.depthb); fb_rtt.depthb = 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
|
//return gl texture
|
||||||
rv.height = tf->h;
|
rv.height = tf->h;
|
||||||
rv.width = tf->w;
|
rv.width = tf->w;
|
||||||
rv.pdata = tf->pData;
|
rv.pdata = tf->pData;
|
||||||
rv.textype = tf->tex_type;
|
rv.textype = tf->tex_type;
|
||||||
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectCleanup() {
|
void CollectCleanup() {
|
||||||
|
@ -602,6 +635,30 @@ void CollectCleanup() {
|
||||||
void DoCleanup() {
|
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()
|
void killtex()
|
||||||
{
|
{
|
||||||
for (TexCacheIter i=TexCache.begin();i!=TexCache.end();i++)
|
for (TexCacheIter i=TexCache.begin();i!=TexCache.end();i++)
|
||||||
|
|
|
@ -378,7 +378,6 @@ public class OptionsFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//----------------------------------------
|
|
||||||
String[] rtts = getResources().getStringArray(R.array.rtt);
|
String[] rtts = getResources().getStringArray(R.array.rtt);
|
||||||
Spinner rtt_spnr = (Spinner) getView().findViewById(R.id.rtt_spinner);
|
Spinner rtt_spnr = (Spinner) getView().findViewById(R.id.rtt_spinner);
|
||||||
ArrayAdapter<String> rttAdapter = new ArrayAdapter<>(
|
ArrayAdapter<String> rttAdapter = new ArrayAdapter<>(
|
||||||
|
@ -394,7 +393,6 @@ public class OptionsFragment extends Fragment {
|
||||||
public void onNothingSelected(AdapterView<?> arg0) {
|
public void onNothingSelected(AdapterView<?> arg0) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//----------------------------------------
|
|
||||||
|
|
||||||
OnCheckedChangeListener limitfps_option = new OnCheckedChangeListener() {
|
OnCheckedChangeListener limitfps_option = new OnCheckedChangeListener() {
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,6 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rtt(JNIEnv *env,jobje
|
||||||
settings.dreamcast.rttOption = rtt;
|
settings.dreamcast.rttOption = rtt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_limitfps(JNIEnv *env,jobject obj, jint limiter)
|
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_limitfps(JNIEnv *env,jobject obj, jint limiter)
|
||||||
{
|
{
|
||||||
settings.aica.LimitFPS = limiter;
|
settings.aica.LimitFPS = limiter;
|
||||||
|
|
Loading…
Reference in New Issue