summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
AgeCommit message (Collapse)Author
2010-05-27lets apply some mathematical magic:Rodolfo Osvaldo Bogado
* optimize may last commit to make it faster * reorder the code to make it more readable please test and enjoy git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5520 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-05-27ultra experimental commit. fixed tev functionality, now it must be almost ↵Rodolfo Osvaldo Bogado
perfect emulating native hardware. please test as many games as you can this should impact a lot of games. enjoy git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5511 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-05-23Rework the logic for avoiding lerp() in shader codepierre
This should give the exact same shader code except for the cases of SELA == SELB and SELC == 1, the latter only for the color combinder. In these two cases the results of the shader should not change in any way. It would have been possible to optimize the SELC == HALF case too, if the actual factor had been 0.5f instead of 0.4980392f. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5472 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-05-22Use symbolic names instead of numbers and bump cache versionpierre
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5464 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-05-22Modify r5462 as requested by rodolfoosvaldobogadopierre
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5463 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-05-22The result of the last texenv stage is used regardless of destination registerpierre
The real hardware probably always sends the result of its computations to the alpha test/fog units, in parallel to its registers, but those only take the result of the last texenv stage. This makes grass show up in ZTP, where the last texenv stage oddly writes to reg #3 instead of #0. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5462 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-05-17a little optimization in shaders constants setting , based on the same idea ↵Rodolfo Osvaldo Bogado
of nodchip changes. a MAYORRRRRR change in pixel shader generation, please review all games you can and leave comments this must improve accuracy in graphic emulation a lot. for example: mario eyes in super mario galaxy, water pod transparency an water transparency on game intro in super mario sunshine, etc. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5457 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-04-03back to limit vps instead of fps as this fix fps limit and now it works ↵Rodolfo Osvaldo Bogado
correctly as now the sync between the plug in and the core is almost correct. fixed fps display in the top bar, now it shows the real fps of the game. some code clean up and some corrections to make everything work right in the reference renderer. multiples xfb now is broken even in single core as is was not an error caused by dual core, i really dono where the error is,everything looks correct but if you test a game with multiples xfb or the ipl you will see the error. ector if you can take a look at he code and throw me some ideas i'll thank you. please test. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5272 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-02-24Systematically eliminating compiler warnings.Glenn Rice
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5117 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-19Small fixes:Rodolfo Osvaldo Bogado
in opengl correct an error introduced by mi in efb to ram alignment, it's seems to fix SMS but it missalign a lot of other games, so revert to the default. must solve truncated coins in NSMB. revert alpha testing values to the values in rev 4812 as they fix some games. in d3d dynamized the Render target size so it will change at runtime when viewport exceed it size, in the worse case it will cause a missing frame when resizing but in the games I tested is not noticeable at all This must solve all the remaining viewports problems in nvidia cards, in ati this is not needed. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4888 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-17Shader Disk Cache implementation for D3D. Saves generated shaders on disk. ↵hrydgard
Eliminates "freeze jerks" in D3D plugin the _second_ and later times you play something.... not much to do about the first time. The D3D shader compiler is just slow. Also assorted cleanup around the shader code. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4869 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-15ok big changes here:Rodolfo Osvaldo Bogado
in videocommon little fix for the alpha test values, return to the original values as they are more accurate. in D3D: huge change in state management, now all the state management is centralized and redundant state changes are eliminated. Fixed the overlapped viewport error in non ati cards: the error was caused by this: when a viewport is defined larger than the current rendertarget, an error is thrown and the last valid viewport is used, this is the reference behavior, in ati cards if a larger viewport is defined, no eror is returned, the rendering is valid and is rendered using the projection defined by the viewport but limited to the rendertarget are, exactly like opengl or the GC hardware. to solve this in reference drivers defined a large rendertarget (2x the size of the original) and proceed to render in a centered quad insithe the larger rendertarget, in this way larger viewports always falls inside a valid rendertarget size, the drawback of this is the waste of resources. it can be dynamized, depending or games or changed at runtime when a oversized viewport is detected, but i live that to future commits. please test this and let me know the results. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4841 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-12this is a dev commit, a cleanup in the pixel shader generator to make the ↵Rodolfo Osvaldo Bogado
generate code a lot cleaner and readable, and a little fill rate optimization when using alpha test, i don't thing any game is limited by fill rate but the code looks more cleaner and is ordered in the same way is executed in hardware. please test, if any problem apears let me know git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4812 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-02I'm back, after two weeks pure work and nothing of dolphin, take a look at ↵Rodolfo Osvaldo Bogado
the code and discover this very small fix, apply color clamping before alpha test, the way is done in the software plugin, have some nice effects, this will fix some things and brake others but the feedback is needed. if you want to know where to start testing look at SMS :) HAPPY 2010 for everyone git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4775 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-12-07mixed commit:Rodolfo Osvaldo Bogado
in D3D and Opengl: fixed one nasty bug in texture loading where if a dynamic texture keeps his format but the tlut format is changed, the try or reloading the texture in the same texture could cause a hang if the size of the resulting texture is different than the original (size in bytes) Applied a ugly temporal hack to the texture conversor to solve efb to ram misalignments and effect distortions. in D3D: Pseudo implementation of logic ops using basic blending: the first 8 operations are "good approximations", the remaining 8 are bullshit :) if someone have a better approximation to emulate this logic please let me know. please test if i don't break anything in the process and test Mario kart wee you will get a nice surprise.:) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4656 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-11-22big commit, implemented depth textures with hardware support in D3D, so now ↵Rodolfo Osvaldo Bogado
they will be correct as in opengl. please test a lot because i only tested the ati path, nvidia path is "Theoretical" :). Also reimplemented screen clearing as a color quad to support alpha blending when clearing as in the original hardware. the funny thing is how is implemented peeking, as locking depth textures is not supported, implemented peeking copying the values form the depth texture to a r32f render target and then reading back the data. please a lot of testing to this commit. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4599 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-11-21Try to do Z textures better. Z texturing does not work if early z or no z ↵donkopunchstania
update. Corrected the Z texture bias used on 8 and 16 bit textures. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4596 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-11-10Implemented secondary path for hardware with no multiples render target ↵Rodolfo Osvaldo Bogado
support, so please a lot of testing from people with problems in the last release. corrected a little depth textures still broken but now at least i discover the reason, the ultra bad news for d3d lover is, the only correct way to implement depth textures will be do a firs depth only pass disabling blending. This is because blending is affecting the values stored in the depth texture, so to store the true values, blending mus be deactivated. this will degrade performance but is the only "Correct" way in d3d 9. the other possibility is dx10 but that's a complete different story ;) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4526 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-11-08Big Commit this will break a lot, fix a lot, but i thing is a good step:Rodolfo Osvaldo Bogado
Implemented all the correct format conversions in efb to texture copy. replaced all the stretcrect calls with quad draws this must improve speed a bit. A BIGGGGGGGGGG cleanup in the code and reorganization. reimplemented zpeek using a secondary render target ( this still is buggy so many issues left) please a lot off feedback. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4520 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-10-30small code cleanup, and little fixing of errors introduced by mi in my first ↵Rodolfo Osvaldo Bogado
commit :( fixed scissor test in direct 3d git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4480 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-10-29rewrite the tev stages generator to make it more hardware like, thanks to ↵Rodolfo Osvaldo Bogado
godisgovernment for he documentation. Also make it faster using lockup tables. thinking going to get a lot of -1 for this one but is the only for of really test it. hope this fix something and don't break to much ;) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4475 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-10-28small commit,but should fix 2 big issues:Rodolfo Osvaldo Bogado
* clear and flicker problem in d3d, backbuffer clearing was commented out, (if this was on right let me know and I'll revert). * alpha problem introduced by my modifications to the tev, must been sleeping when i wrote that code, should be fixed now. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4471 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-10-25small code clean up:Rodolfo Osvaldo Bogado
d3d: remove the depth texture path it will not work so for now only lockable textures were available. i thing the only way will be a use a secondary render target and do a depth pass to mimic depth textures. opengl: minor cleanup here and there and a possible fix to issue 1509, but not tested because in my system the errors remarked in the issue don't show. commond: code reorganization an optimization in the pixel shader generator, trying to understand the tev stages, make some changes to make the generator faster (not much only started for the alpha test and fog). this changes try start solving the diferences bethen the hardware plugins and the soft plugin. i hope with i don't brake nothing but please test this a lot. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4465 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-10-14Videocommon: setlocale for shader compilation, should fix problem with ↵nakeee
runaway , in certain locales. Please test issues 1533 and 1496 git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4418 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-09-16Tiny shader syntax fix that was here for a while now.XTra.KrazzY
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4285 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-09-13D3D: Eliminate black borders, add 4:3 and 16:9 settings, and the widescreen ↵hrydgard
hack. Unfortunately this temporarily breaks MSAA (in d3d only) until I have time to fix it. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4263 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-09-10D3D: Minor bug fix and some code cleanup for DirectX API call reduction.rice1964
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4244 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-09-06Add some command line options to directly specify plugins. You can use ↵rice1964
"dolphin /V Plugins/Plugin_Video???.dll" in the command line to start Dolphin with the ??? plugin. This can be done also for other plugins. There are a couple of reasons to do so. For example, Dolphin compiled in DEBUG would often crash if loaded with non-DEBUG plugins. Therefore, you may want use to DEBUG plugins when running the DEBUG dolphin by giving all the command switches. Also add some code to show the version of the plugin in the plugin configuration window title, so we can see clearly which version of the plugin we are using. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4208 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-09-02D3D: Fix nonpow2 textures (simply turn off the rect texture stuff since it's ↵hrydgard
not necessary under D3D). some cleanup. Add a TODO (tip from Orphis) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4168 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-09-01D3D: Fix bugs in the shader cache, fixes crashes on x64. added some ↵hrydgard
debugging stuff (only active in debug builds). assorted code cleanup. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4145 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-08-31D3D: Fix alpha test (I think, not tested much, no pun intended)hrydgard
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4124 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-08-31Some optimization on the pixel and vertex shader generators. As tested on ↵rice1964
Zelda TP, these changes should be able to reduce the number of lines in the compiled pixel shader program by 20% to 30%, for example, from 38 lines to 28 lines after the generated cg/HLSL pixel shader compiled by the cg/HLSL compiler. These could means slightly faster rasterization on slower video cards. Also fixed shader compilation errors for DX9 plugin by using correct pixel/vertex attribute names that are compatibile with DX9 HLSL shader compiler. Now the generated vertex or pixel shader programs will compile correctly in either OGL or DX9. However, DX9 plugin is still not fixed, even though the shader programs can be compiled now. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4113 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-07-28Now ALL copyright dates are fixed to the legally correct year: The year in ↵XTra.KrazzY
which the project began. Now we don't have to change it every year :) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3898 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-07-26Log unknown fog types in Warn log, and tiny code cleanup.omegadox
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3885 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-07-26GFX: updated Dates, code formatting cleanup, code cleanup / organization, ↵omegadox
some unknown BPs uncovered, fixed OGL's config dialog bug, added another shader DSPHLE: Some warning fixes and added some logging for unknown voice cases Please report if anything has broken. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3884 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-07-19Roll back r3833 for render targets but keep it for static textures. Most ↵hrydgard
mirroring issues are OK and we shouldn't see any slowdown. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3844 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-07-18GL: Delete code for GL_TEXTURE_RECTANGLE_ARB in case of non-pow2 textures - ↵hrydgard
all modern GFX cards that can run Dolphin should support non-pow2 textures anyway. This removes some complexity and reduces the numbers of pixel shaders that need to be generated in some situations. Also fixes some texture mirroring problems. Let me know if this breaks things on ATI for some reason. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3833 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-07-03Assorted cleanup, perf counter logging, and minor fixes that have been ↵hrydgard
accumulating on my hdd :p git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3663 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-06-22revert last 2 commitsnakeee
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3533 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-06-22They should be called SU Registers (Setup Unit/Rasterization). BP (Bypass) ↵omegadox
is really the name of the commands that are passed in. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3531 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-05-15Changing where depth is read. Trying to use the same depth buffer GL uses ↵donkopunchstania
when copying depth to a texture. This eliminates some quirky code and gets depth copies working in AA, but may not work on older graphics cards. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3234 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-05-13Possible fix for S3TC Texture Decoding (Grass in ZWW is now properly alpha ↵omegadox
tested), and some code formatting cleanup. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3224 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-04-15revised how texture scaling is handled. it now works correctly when adding ↵donkopunchstania
output together from indirect stages which use power 2 and non power 2 textures and it is simpler. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2972 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-04-11Did clean up of indirect texture look up and fixed some bugs related to ↵donkopunchstania
indirect unit. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2954 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-03-16Change destination alpha handling. The blending method introduced in rev ↵donkopunchstania
1921 was not the correct way to do it. This way was suggested by hrydgard in October and I should have listened. A simple pixel shader as hrydgard suggested cannot be used because the alpha is not set if the pixel is discarded due to failing depth (after z texture) or alpha (result of tev stages) tests. There is a bit of a performance hit so there should be an option to disable the second render pass which sets the alpha because it is probably not needed most of the time. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2662 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-03-05Linux compile fix.Marcus Wanners
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2559 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-03-05Compiler Warnings: Mismatch edition. Also fixed some conversion warnings.Marcus Wanners
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2557 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-03-05Fix more cases where shader compilation can fail if there are no tex gens.donkopunchstania
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2556 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-03-01revert the mess i made in the d3d plugin. Add way to use HLSL directly ↵hrydgard
without going through Cg. Not that the results look much better... i do see shadows of spinning cars in Burnout 2 after clicking around in the dark. Then it crashes. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2504 8ced0084-cf51-0410-be5f-012b33b47a6e
2009-03-01An alert is displayed once per run if pixel shaders or vertex shaders fail ↵donkopunchstania
to compile. Resources are cleaned up if shader compilation fails. Tev coords are zeroed in the pixel shader if there are no tex gens. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2493 8ced0084-cf51-0410-be5f-012b33b47a6e