Commit Graph

263 Commits

Author SHA1 Message Date
baldurk 2717e05b48 Save draw and read framebuffer bindings, add some more TODOs 2014-08-15 12:33:32 +01:00
baldurk 7d52069401 Get initial sampler bindings 2014-08-15 12:20:18 +01:00
baldurk 0a83acef51 Pre-bake into pipeline and program data shader IDs per stage 2014-08-15 11:15:38 +01:00
baldurk 4352317f52 Instead of tracking layout, query variable's offset & stride
* It's unfortunate to have to use program introspection so heavily like
  this (perhaps there should be a GL-specific shader reflection structure
  like DXBC where these locations and strides could be cached), but it's
  not too bad and handles any arbitrary layout
2014-08-14 17:08:45 +01:00
baldurk bd4efeedcd Work in progress filling of UBO values. Not correct yet 2014-08-14 16:22:03 +01:00
baldurk e54aed0c2b Always consider non-buffer-backed uniform blocks as used 2014-08-14 14:29:20 +01:00
baldurk 6f35d1fb27 Correctly generate nested structure/AoS types in GL uniforms 2014-08-14 12:06:33 +01:00
baldurk cb89bc5891 Fix wrong value index being used 2014-08-13 17:01:16 +01:00
baldurk 6a6aa9b446 Handle what should be all the GL uniform types 2014-08-13 16:23:20 +01:00
baldurk 7ab9815aaf Introduce a bindpoint mapping as part of the pipeline state
* For APIs where the shader namespace/bindpoint (which may be arbitrary
  like 'the Nth texture resource' can be mapped, at each event, to the
  actual API bind point where the object is.
* On D3D11 this is pass-through, on GL this returns the value of each
  uniform.
* This also means GL shader reflection structures are properly immutable
  and the variance in the uniform values is handled elsewhere.
* In future this might need to be expanded to support more complex binding
  methods, where the mapping returns the resource rather than just mapping
  to an integer bind ponit.
2014-08-13 15:56:55 +01:00
baldurk a56608e0cd Hook glGetProgramResourceIndex 2014-08-13 15:53:55 +01:00
baldurk 3d09b6ad28 Use the right name length value! 2014-08-13 15:33:40 +01:00
baldurk 279c43c352 Add a couple more variable types, need to fill this in eventually 2014-08-13 15:33:27 +01:00
baldurk 5df45e8b5b Use correct location for UBOs 2014-08-13 13:29:28 +01:00
baldurk b39d829fbf A few optimisations in cases where *tons* of LoadLibrary calls happen
* Bail if we find an IAT entry already hooked as it means this module has
  been processed already.
* Avoid allocations/std::string in the ApplyHooks function.
2014-08-13 13:04:07 +01:00
baldurk fe027e61d5 Crash fixes, ensure we read back from valid uniform locations
* We can't use the uniform locations from our separable program as that's
  not guaranteed to be the same in the real program (could end up reading
  a completely different uniform value).
2014-08-13 13:03:12 +01:00
baldurk df5913855e Follow up to last commit, allocate sizeof(char_type), not 1 byte
* This week is apparently not a good week for avoiding stupid mistakes.
2014-08-13 11:11:34 +01:00
baldurk dcbba16af5 Don't assign "" to elems as it can later get free()d invalidly 2014-08-13 09:32:53 +01:00
baldurk ff371ee768 Verify that texture ID is found as tex2d before proceeding 2014-08-12 19:11:59 +01:00
baldurk 8158af7a9f Attempt to make separable shader prog, add input/output fetching
* Also moved shader reflection code into separate file
2014-08-12 17:01:18 +01:00
baldurk ebb5894010 If semantic is empty and we have variable name, use that instead 2014-08-12 16:47:31 +01:00
baldurk 49ab71181c Add some system attributes from GL 2014-08-12 16:47:00 +01:00
baldurk 38866f9829 Update TODO 2014-08-12 16:46:45 +01:00
baldurk fceabf7948 Explicitly handle initing from empty arrays, and assign NULL or "" 2014-08-12 16:46:35 +01:00
baldurk 0c52714def Remove a loop that doesn't need to be there any more 2014-08-09 01:46:00 +01:00
baldurk e7ab52cd22 Skip a few core modules 2014-08-09 01:45:43 +01:00
baldurk 9beaabb83b Make the lock only cover the ApplyHook function 2014-08-09 01:45:11 +01:00
baldurk 1b0eae755a Bail out immediately if IAT entry is already hooked
* This avoids going into VirtualProtect changing the page access while code
  may potentially be executing these areas of memory (since the module is
  hooked, and may have returned to user code)
2014-08-09 01:44:45 +01:00
baldurk aa690d7183 Add lock around hook apply function 2014-08-09 00:36:15 +01:00
baldurk f8bf111e9a Hook all modules, redundantly but safely, on each LoadLibrary() 2014-08-09 00:04:06 +01:00
Baldur Karlsson ec683ea474 Make sure outputs are always erased 2014-08-08 14:01:02 +01:00
Baldur Karlsson 2947e508a6 Fix array overrun 2014-08-08 14:00:50 +01:00
Baldur Karlsson 9eb007f04d Sort of handle separable programs and program pipelines
* Need to find a better way of solving the non-immutable-shader-reflection
  given baked in uniform values. Probably expose the uniform values mapping
  to the user, and for D3D it just becomes trivial and unchanging.
* Also I need to create separable programs per-shader for use for
  reflection in that case, but thanks to the stupid gl_PerVertex
  redeclaration that becomes a nightmare.
2014-08-08 14:00:32 +01:00
Baldur Karlsson 9925392042 Handle half floats as well for position data 2014-08-08 13:56:31 +01:00
Baldur Karlsson e19daa58e3 Check bindpoint isn't -1 (for non-buffer-backed uniforms) 2014-08-08 11:15:16 +01:00
Baldur Karlsson 0c5a549633 Add uint type 2014-08-08 10:41:47 +01:00
baldurk 6b74ce2f65 Add slight delay before calling PixelHistory to allow for painting 2014-08-07 21:43:57 +01:00
baldurk 0202af73da Fetch SV_Coverage value and fill in semantic data. Closes #74 2014-08-06 23:15:28 +01:00
baldurk 4d4243d5bc Fix reference to renamed variable 2014-08-06 22:36:37 +01:00
baldurk 36a67611e5 Handle a few declaration opcodes that had gotten missed 2014-08-06 22:35:47 +01:00
baldurk d3f867d5d3 Set a sane tab order on dialogs 2014-08-06 22:21:27 +01:00
Baldur Karlsson 81ee6a47b0 Refresh module handle if NULL when hitting GetProcAddress
* This might be a more serious problem in future...
* We only hook all loaded modules once, at init time, in Win32_IAT_EndHooks
* If a LoadLibrary call afterwards implicitly loads some modules we don't
  see them. Potentially we should rehook all loaded modules again each time
  LoadLibrary is called but then there would be a lot of redundant work
  unless we tracked module unload/loads to see if a module has been hooked
  before or not. For now assume we don't need to hook these modules and
  get away with just updating module handles
2014-08-06 15:43:17 +01:00
Baldur Karlsson 68e47d3ae2 Skip hooking fraps via IAT for compatibility reasons 2014-08-06 15:43:17 +01:00
Baldur Karlsson f3cc56573f Ignore modules with a invalid DOS magic number
* Seen in the wild some HMODULEs come back pointing 2 bytes after the real
  module base address, and so without the magic number. I don't know why
  but I can't assume anything about the behaviour so I ignore these modules
  to avoid crashes.
2014-08-06 15:43:16 +01:00
Baldur Karlsson 12a30a7b97 Add IAT based hooking to allow hooking 64bit opengl32.dll
* Needs vigorous testing in as many situations as I can think of, not least
  32bit, 64bit, D3D11, D3D9, OpenGL, managed apps, different windows SDKs,
  delay loading dlls (not sure if these will work), statically linked libs,
  LoadLibrary + GetProcAddress
* Credit goes to jslutter for originally bringing it to my attention &
  suggesting it.
* References:
  http://msdn.microsoft.com/en-us/magazine/bb985992.aspx
  http://msdn.microsoft.com/en-us/magazine/cc301808.aspx
  http://www.codeproject.com/Articles/6265/Process-wide-API-spying-an-ultimate-hack
2014-08-06 15:43:16 +01:00
Baldur Karlsson 23543d6a43 length returned from program introspection includes space for '\0' 2014-08-06 15:43:00 +01:00
Baldur Karlsson c648904cba DebugMessage description is an ascii string 2014-08-06 15:42:33 +01:00
Baldur Karlsson 2e3a3ac175 Serialise depth function as part of render state 2014-08-06 12:27:46 +01:00
Baldur Karlsson 9bf0ee93b6 Typo using wrong blend GLenum for source alpha 2014-08-06 12:26:51 +01:00
baldurk 9f9411b758 Merge pull request #75 from valeriog-crytek/master
Added debugging support for GATHER4* opcodes.
2014-08-05 17:57:47 +01:00