EmulatorArchive / jpcsp

Automatically exported from code.google.com/p/jpcsp
1 stars 0 forks source link

Stencil Test observation #354

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
While testing the way to add hd textures to Phantasy Star Portable 2
i realized that stencil test got troublesome in r2459

while one revision before it was working ok

the stencil test is needed for hd textures in this game and in r2458 it was 
giving it,while in 2459 it didn't = resulting in only black screen when enabled

If it can be looked into it would be nice

Original issue reported on code.google.com by IceLance...@gmail.com on 17 Jun 2013 at 11:03

GoogleCodeExporter commented 9 years ago
OK
i narrowed down where is the actual culprit!
videoengine.java
line 4510
        // Texture not used when disabled or in clear mode.
        if (!context.textureFlag.isEnabled() || context.clearMode) {

replace with 
        // Texture not used when disabled or in clear mode.
        if (!context.textureFlag.isEnabled()) {
by removing "clear mode"

and stencil is working again,and HD textures are activated again

i am basically newb to java so i narrowed down to this from my little knowlage 
of how c++ works,so try not to be harsh in judgment please

I hope this helps G to find and actually fix the stencil for PSP2 HD textures

Thanks for listening

Original comment by IceLance...@gmail.com on 17 Jun 2013 at 11:26

GoogleCodeExporter commented 9 years ago
I actually forgot one little line more in same file
so i uploaded patch vs latest svn where i tested that HD textures are working 
with it
i added picture of HD textures as well

http://www9.zippyshare.com/v/74633538/file.html

i know google is very limmited on space :-/ so i uploaded to zippy

Original comment by IceLance...@gmail.com on 17 Jun 2013 at 11:41

GoogleCodeExporter commented 9 years ago
After this
there are still some issues left
controller is still trying to do autoclicking ... :-/
speed of emulator is crippled when stencil is activated..

to counter act that i applied patch for HD 
http://www.emunewz.net/forum/showthread.php?tid=33845&pid=167697#pid167697
posted by shion_chk for r2458

it fixes emulator speed with HD enabled via stencil and weird autoclicking of 
controller!

So after all that there is just one issue remained
latest svn tend to "break" reading of some ground textures when moving camera 
arround,usually only when camera is direct behind
that i don't know how to counteract...

check pictures below to see  

http://img585.imageshack.us/img585/8082/a9fk.jpg
http://img542.imageshack.us/img542/553/n49q.jpg
textures disappear only when camera is directly behind

I hope this can help you in fixing it

BTW
i added link for edited patch from forum for latest svn build
https://mega.co.nz/#!dsYRCYYR!ZhEDxxT0xUSlhpNrdJT3UV4nrAhtAoRJ1NXR-xVoXuA

Original comment by IceLance...@gmail.com on 18 Jun 2013 at 12:51

GoogleCodeExporter commented 9 years ago
somewhat found a "possible solution" to missing textures
shion_chk in his post 
http://www.emunewz.net/forum/showthread.php?tid=33845&pid=167697#pid167697
mentions that he fixed missing textures with 4.6 patch
trouble is that i dont know what was actually fixed compared to his 4.5
it leaves me that i missed soemthing from his patch when applied to latest svn 
:-/
or his patch is not latest patch with included fixes

Original comment by IceLance...@gmail.com on 18 Jun 2013 at 1:22

GoogleCodeExporter commented 9 years ago
found a "fix" for missing legs and textures...
VideoEngine 
under :  private void executeCommandZSCALE()
add   :  floatArgument = floatArgument/2;

here is finished patch
https://mega.co.nz/#!Rt5FERZY!Xtv8dw4ZwdM4bk2jyOSmWARcPsVJll0JO6vq8KmbD-0

I really hope all this can help G to fix the game without all this :)

Btw screen might flicker when entered game sometimes..its same as with old 
patches and versions,the only way to fix flickering is to resize window untill 
it stops flickering..

FMV's Are working! :)

Original comment by IceLance...@gmail.com on 18 Jun 2013 at 2:53

GoogleCodeExporter commented 9 years ago
game suffers from hle crashes after same ammount of time,with any revision 
/build/patch

the only way to prevent crash is to turn off "decoding sounds with sonic stage"
bgm's from game will be gone,but sounds will still be there and it wont crash 
any more 

Original comment by IceLance...@gmail.com on 18 Jun 2013 at 10:53

GoogleCodeExporter commented 9 years ago
i broke down patch to only 3 file changes
*videoengine
floatArgument = floatArgument/2;
-fixes missing legs and textures when rotatin camera

-rest in videoengine enables HD textures when using stencil instead of just 
black screen

*REShader
changes in here speed up emulator to full 30fps when using stencil,without it 
speed is barrely 7fps on oc intel 4.4ghz

*ThreadManForUser
changes in here
fixes controller autoclicking in this game

Original comment by IceLance...@gmail.com on 19 Jun 2013 at 2:55

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you! Just saw your issue now.

Original comment by gi...@web.de on 21 Jun 2013 at 1:53

GoogleCodeExporter commented 9 years ago
    Does it also happens when selecting the menu Options -> Video -> Resize -> 2x (or 3x)? Or is it just happening when resizing the window manually.

-----------------------------------------------------------------
No
Borders don't exist when using menu scaling 1-3.only flickering
altough 3x windows resize is too small for my big screen ,hence manual resize 
or at least x5 window resize (2048x1152)

OK another test,if i use [] max resize square button near minimize psp2 doesnt 
have borders any more!
So window resize 2-3 and "max resize eliminate borders for this game,only 
flickering remain

But some older game gets textures jumping out of place :

So i took liberty to test some other games with this line change
and it seems that Joan of Arc got some textures jumping "out of place" with it
even with window->resize 2-3
http://imageshack.us/photo/my-images/211/6w9m.jpg/
as u can see head of npc which should be way above is now at bottom border line
and other npc's and players textures also jumped out of place

-----------------
EDIT
theres another problem
if using that line to fix hd textures without need for stencil,it kills 
emulator speed totally.
with window resize x3 i barely have 12fps in game
nvidia 560ti 1gb ddr5/ 4.4ghz 2500k intel

So how about possibility of adding some "hack fixes" for special games?
this game example?make stencil activates hd textures without sacrificing the 
speed?and breaking other games?

P.S
adding REShader.java changes from patch boost speed of game back to full speed 
(with your line for hd and no need for stencil)
so maybe shaders still have some issues?

Found a way to restore speed to emulator with your line,but i dont get it how 
is that related when it was suppose to be part of stencil,and stencil isnt 
used!its not even enabled in options but speed is back to 30 fps with just this 
change?!?
line 164/165/166

if (useShaderStencilTest) {
Code:
        useShaderAlphaTest = true;
            useShaderBlendTest = true;
            useShaderDepthTest = true;
to :
Code:
            useShaderAlphaTest = false;
            useShaderBlendTest = false;
            useShaderDepthTest = false;
according to this it looks like Stencil test is Always used??and if "true" 
(even disabled) it will cripple emulator speed when using ge to textures for 
HD,but false makes speed back.

it doesnt have any negative impact on any game i tested if set to "false" it 
actually boost fps in few games! 

Original comment by IceLance...@gmail.com on 21 Jun 2013 at 3:37

GoogleCodeExporter commented 9 years ago
Are you sure you have no other modification in your REShader source code?
Check your Settings.properties file: it should contain
    emu.enableshaderstenciltest=0
when the shader test is disabled.

Line 143 is reading it:
        useShaderStencilTest = Settings.getInstance().readBool("emu.enableshaderstenciltest");

Original comment by gi...@web.de on 21 Jun 2013 at 4:31

GoogleCodeExporter commented 9 years ago
i guess i made mistake there
stencil got "sneaked" in somehow in tests resulting in fps crippled

its all good now
textures are hd ,need to use "max resize" for my screen tho

So
only this issues remain
-screen flickering need multiple resize sometimes up to 5 mins resizing to get 
clear screen

-your line in videoengine makes other games get some problems ,Joan of Ark 
example
textures move out of their positions

-missing legs and textures rendered on z scale
"floatArgument = floatArgument/2;"

-// The PSP seems to have a resolution of 200us
    protected static final int THREAD_DELAY_MINIMUM_MICROS = 200;
200 is not suitable for this game ,controller is autoclicking
protected static final int THREAD_DELAY_MINIMUM_MICROS = 16;
16 seems to be correct

-and last enabling soundstage crashes game after 15mins of play in hle (bgm)

Original comment by IceLance...@gmail.com on 21 Jun 2013 at 5:13

GoogleCodeExporter commented 9 years ago
i have tested couple more games,and none except Joan of Arc seems to be 
affected by video change
i wasn't completely thorough but at first glance none seem to have problems (10 
games test)
So biggest issue right now is that screen flicker in psp2 which i cant trace

Original comment by IceLance...@gmail.com on 21 Jun 2013 at 5:48

GoogleCodeExporter commented 9 years ago
Joan of Arc is only game in my lot thats 2D and not 3D (battle screen is 2D)
maybe some other 2D games are affected,but i dont have any other 2D

Original comment by IceLance...@gmail.com on 21 Jun 2013 at 5:50

GoogleCodeExporter commented 9 years ago
OK
i have found "somewhat" solution to flickering
but that break fmv's..
enabling "only GE" then resizing game till flicker stops,
then restarting emulator ,seems to "remember" the graphic and doesn't flicker
tried multiple times and flickering is gone after restarting emulator which 
once saved "non flickering graphic"

But as i said using Only GE breaks fmv's in game only black screen shows..

Original comment by IceLance...@gmail.com on 21 Jun 2013 at 7:04

GoogleCodeExporter commented 9 years ago
About the following change:

protected static final int THREAD_DELAY_MINIMUM_MICROS = 16;

is 16 the maximum value still working? Or would another value closer to 200 
also work (e.g. 100). The reason is that 200 is matching tests done on a real 
PSP, and I would not like to change it too much without a good reason.

Original comment by gi...@web.de on 26 Jun 2013 at 4:12

GoogleCodeExporter commented 9 years ago
16 is working precisely any higher makes autocklicking 
i understand that 200 is more precise according to psp,but none game so far 
showed any odd behavior with 16 or higher except this game,controller is moving 
and clicking all by it self with any higher 

Original comment by IceLance...@gmail.com on 26 Jun 2013 at 5:27