Am 04.01.2012 17:26, schrieb Henri Verbeet:
2012/1/5 Rico Schüllerkgbricola@web.de:
I'm not sure what you mean by a "normal handle table".
Do you mean a list?
It's pretty much just a table of handles. There are a couple of different variants spread over the Wine source. For example, http://source.winehq.org/git/wine.git/blob/HEAD:/dlls/ddraw/main.c#l50 is what ddraw uses.
Well that's a list, isn't it? So we are talking about the same thing. I'm not sure that's the best solution. Since you could pass pointers to strings as handles, I'd like to show the following example: char *name="test"; address may be: name -> 0x80484c4 Now what happens if the address is equal the index of another variable? You'd get the wrong variable. You couldn't safely say from the value if it is a name or a handle! So the only option I see is to use the address of the handle as index, which would require a sorted list or something like a rbtree and also would be cpu expensive for comparison if the "index" is in the list. Keep in mind the list could get big and the handles have to be compared every usage (maybe several times per frame). You'd have to compare against all handles, not only the small amount in one shader... and each element and struct member has it's own handle. That's why I think a table wouldn't do the trick. What do you think?
The detection by something like the address //((UINT_PTR)ptr) & (1 << (sizeof(UINT_PTR)*8-1))// (see http://www.winehq.org/pipermail/wine-devel/2010-April/082900.html ) may not be save either, but it is a lot better in concerns of speed and it is what some people think native does! So it might be the most compatible way to do it.
Cheers Rico