Commit ddab7fcd authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dcompiler: Make SlWriteBytecode return the shader size.

parent c2073b7b
...@@ -2543,22 +2543,8 @@ static HRESULT call_instr_handler(struct bc_writer *writer, ...@@ -2543,22 +2543,8 @@ static HRESULT call_instr_handler(struct bc_writer *writer,
return E_INVALIDARG; return E_INVALIDARG;
} }
/* SlWriteBytecode (wineshader.@) HRESULT SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result, DWORD *size)
* {
* Writes shader version specific bytecode from the shader passed in.
* The returned bytecode can be passed to the Direct3D runtime like
* IDirect3DDevice9::Create*Shader.
*
* Parameters:
* shader: Shader to translate into bytecode
* version: Shader version to generate(d3d version token)
* dxversion: DirectX version the code targets
* result: the resulting shader bytecode
*
* Return values:
* S_OK on success
*/
DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result) {
struct bc_writer *writer; struct bc_writer *writer;
struct bytecode_buffer *buffer = NULL; struct bytecode_buffer *buffer = NULL;
HRESULT hr; HRESULT hr;
...@@ -2610,12 +2596,8 @@ DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD ...@@ -2610,12 +2596,8 @@ DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD
goto error; goto error;
} }
/* Cut off unneeded memory from the result buffer */ *size = buffer->size * sizeof(DWORD);
*result = d3dcompiler_realloc(buffer->data,
sizeof(DWORD) * buffer->size);
if(!*result) {
*result = buffer->data; *result = buffer->data;
}
buffer->data = NULL; buffer->data = NULL;
hr = S_OK; hr = S_OK;
......
...@@ -396,9 +396,8 @@ static HRESULT assemble_shader(const char *preproc_shader, ...@@ -396,9 +396,8 @@ static HRESULT assemble_shader(const char *preproc_shader,
struct bwriter_shader *shader; struct bwriter_shader *shader;
char *messages = NULL; char *messages = NULL;
HRESULT hr; HRESULT hr;
DWORD *res; DWORD *res, size;
LPD3DBLOB buffer; ID3DBlob *buffer;
int size;
char *pos; char *pos;
shader = SlAssembleShader(preproc_shader, &messages); shader = SlAssembleShader(preproc_shader, &messages);
...@@ -443,7 +442,7 @@ static HRESULT assemble_shader(const char *preproc_shader, ...@@ -443,7 +442,7 @@ static HRESULT assemble_shader(const char *preproc_shader,
return D3DXERR_INVALIDDATA; return D3DXERR_INVALIDDATA;
} }
hr = SlWriteBytecode(shader, 9, &res); hr = SlWriteBytecode(shader, 9, &res, &size);
SlDeleteShader(shader); SlDeleteShader(shader);
if (FAILED(hr)) if (FAILED(hr))
{ {
...@@ -453,7 +452,6 @@ static HRESULT assemble_shader(const char *preproc_shader, ...@@ -453,7 +452,6 @@ static HRESULT assemble_shader(const char *preproc_shader,
if (shader_blob) if (shader_blob)
{ {
size = HeapSize(GetProcessHeap(), 0, res);
hr = D3DCreateBlob(size, &buffer); hr = D3DCreateBlob(size, &buffer);
if (FAILED(hr)) if (FAILED(hr))
{ {
......
...@@ -570,7 +570,7 @@ typedef enum _BWRITERDECLUSAGE { ...@@ -570,7 +570,7 @@ typedef enum _BWRITERDECLUSAGE {
#define T3_REG 5 #define T3_REG 5
struct bwriter_shader *SlAssembleShader(const char *text, char **messages) DECLSPEC_HIDDEN; struct bwriter_shader *SlAssembleShader(const char *text, char **messages) DECLSPEC_HIDDEN;
DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result) DECLSPEC_HIDDEN; HRESULT SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result, DWORD *size) DECLSPEC_HIDDEN;
void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN; void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN;
#define MAKE_TAG(ch0, ch1, ch2, ch3) \ #define MAKE_TAG(ch0, ch1, ch2, ch3) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment