Skip to content

Commit

Permalink
helpers: Improve D3D8/9 shader size computation once again.
Browse files Browse the repository at this point in the history
Based on [email protected]'s comment.
  • Loading branch information
jrfonseca committed Aug 27, 2019
1 parent 68328e0 commit debbeb4
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions helpers/d3dcommonsize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,35 +134,28 @@ _shaderSize(const DWORD *pFunction)
if (dwToken & 0x80000000U) {
continue;
}

// FIXME:
// Code that should advance over comment tokens and raw data tokens for sm 1_x is not fail safe
// keeping chances of false D3DSIO_END is better then crashing

/*

D3DSHADER_INSTRUCTION_OPCODE_TYPE opcode = D3DSHADER_INSTRUCTION_OPCODE_TYPE(dwToken & D3DSI_OPCODE_MASK);
switch (opcode) {
case D3DSIO_COMMENT:
dwLength += (dwToken & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT;
break;
//this opcodes contain raw data, so they can't be processed with bit 31 test
case D3DSIO_DEFB:
dwLength += 2;
break;
case D3DSIO_DEFI:

case D3DSIO_DEF:
// Contains raw floating point so can't be advanced with the 31 bit test.
// NOTE: DEFB/DEFI are SM 2 only.
dwLength += 5;
break;
default:

case D3DSIO_END:
// https://docs.microsoft.com/en-us/windows-hardware/drivers/display/end-token
if (dwToken == D3DSIO_END) {
return dwLength * sizeof *pFunction;
}
break;

default:
break;
}
*/

// https://docs.microsoft.com/en-us/windows-hardware/drivers/display/end-token
if (dwToken == D3DSIO_END) {
return dwLength * sizeof *pFunction;
}
}
}
Expand Down

0 comments on commit debbeb4

Please sign in to comment.