wined3d: Add functions to initialize and free shader buffers.
This commit is contained in:
parent
acbdd807b6
commit
4997bee1bf
|
@ -2694,10 +2694,7 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWi
|
|||
}
|
||||
|
||||
/* Shader header */
|
||||
buffer.bsize = 0;
|
||||
buffer.lineNo = 0;
|
||||
buffer.newline = TRUE;
|
||||
buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
|
||||
shader_buffer_init(&buffer);
|
||||
|
||||
shader_addline(&buffer, "!!ARBfp1.0\n");
|
||||
|
||||
|
@ -2888,7 +2885,7 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWi
|
|||
FIXME("Fragment program error at position %d: %s\n", pos,
|
||||
debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, buffer.buffer);
|
||||
shader_buffer_free(&buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -3426,10 +3423,7 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu
|
|||
struct arbfp_blit_priv *priv = (struct arbfp_blit_priv *) device->blit_priv;
|
||||
|
||||
/* Shader header */
|
||||
buffer.bsize = 0;
|
||||
buffer.lineNo = 0;
|
||||
buffer.newline = TRUE;
|
||||
buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
|
||||
shader_buffer_init(&buffer);
|
||||
|
||||
ENTER_GL();
|
||||
GL_EXTCALL(glGenProgramsARB(1, &shader));
|
||||
|
@ -3438,7 +3432,7 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu
|
|||
checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader)");
|
||||
LEAVE_GL();
|
||||
if(!shader) {
|
||||
HeapFree(GetProcessHeap(), 0, buffer.buffer);
|
||||
shader_buffer_free(&buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3493,7 +3487,7 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu
|
|||
case YUV_FIXUP_YUY2:
|
||||
if (!gen_planar_yuv_read(&buffer, yuv_fixup, textype, &luminance_component))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, buffer.buffer);
|
||||
shader_buffer_free(&buffer);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -3501,14 +3495,14 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu
|
|||
case YUV_FIXUP_YV12:
|
||||
if (!gen_yv12_read(&buffer, textype, &luminance_component))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, buffer.buffer);
|
||||
shader_buffer_free(&buffer);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("Unsupported YUV fixup %#x\n", yuv_fixup);
|
||||
HeapFree(GetProcessHeap(), 0, buffer.buffer);
|
||||
shader_buffer_free(&buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3533,7 +3527,7 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu
|
|||
FIXME("Fragment program error at position %d: %s\n", pos,
|
||||
debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, buffer.buffer);
|
||||
shader_buffer_free(&buffer);
|
||||
LEAVE_GL();
|
||||
|
||||
switch (yuv_fixup)
|
||||
|
|
|
@ -40,6 +40,20 @@ static inline BOOL shader_is_version_token(DWORD token) {
|
|||
shader_is_vshader_version(token);
|
||||
}
|
||||
|
||||
void shader_buffer_init(struct SHADER_BUFFER *buffer)
|
||||
{
|
||||
buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE);
|
||||
buffer->buffer[0] = '\0';
|
||||
buffer->bsize = 0;
|
||||
buffer->lineNo = 0;
|
||||
buffer->newline = TRUE;
|
||||
}
|
||||
|
||||
void shader_buffer_free(struct SHADER_BUFFER *buffer)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, buffer->buffer);
|
||||
}
|
||||
|
||||
int shader_addline(
|
||||
SHADER_BUFFER* buffer,
|
||||
const char *format, ...) {
|
||||
|
|
|
@ -2958,10 +2958,7 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs
|
|||
char reg_mask[6];
|
||||
const struct semantic *semantics_out, *semantics_in;
|
||||
|
||||
buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
|
||||
buffer.bsize = 0;
|
||||
buffer.lineNo = 0;
|
||||
buffer.newline = TRUE;
|
||||
shader_buffer_init(&buffer);
|
||||
|
||||
shader_addline(&buffer, "#version 120\n");
|
||||
|
||||
|
@ -3093,7 +3090,7 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs
|
|||
GL_EXTCALL(glCompileShaderARB(ret));
|
||||
checkGLcall("glCompileShaderARB(ret)");
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, buffer.buffer);
|
||||
shader_buffer_free(&buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -277,14 +277,9 @@ static inline GLuint IWineD3DPixelShaderImpl_GenerateShader(
|
|||
SHADER_BUFFER buffer;
|
||||
GLuint shader;
|
||||
|
||||
buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
|
||||
buffer.bsize = 0;
|
||||
buffer.lineNo = 0;
|
||||
buffer.newline = TRUE;
|
||||
|
||||
shader_buffer_init(&buffer);
|
||||
shader = ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_generate_pshader((IWineD3DPixelShader *)This, &buffer);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, buffer.buffer);
|
||||
shader_buffer_free(&buffer);
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
|
|
@ -325,14 +325,9 @@ static void IWineD3DVertexShaderImpl_GenerateShader(IWineD3DVertexShader *iface,
|
|||
|
||||
find_swizzled_attribs(decl, This);
|
||||
|
||||
buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
|
||||
buffer.bsize = 0;
|
||||
buffer.lineNo = 0;
|
||||
buffer.newline = TRUE;
|
||||
|
||||
shader_buffer_init(&buffer);
|
||||
((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_generate_vshader(iface, &buffer);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, buffer.buffer);
|
||||
shader_buffer_free(&buffer);
|
||||
}
|
||||
|
||||
/* *******************************************
|
||||
|
|
|
@ -2229,6 +2229,8 @@ typedef struct IWineD3DBaseShaderImpl {
|
|||
HRESULT WINAPI IWineD3DBaseShaderImpl_QueryInterface(IWineD3DBaseShader *iface, REFIID riid, LPVOID *ppobj);
|
||||
ULONG WINAPI IWineD3DBaseShaderImpl_AddRef(IWineD3DBaseShader *iface);
|
||||
ULONG WINAPI IWineD3DBaseShaderImpl_Release(IWineD3DBaseShader *iface);
|
||||
void shader_buffer_init(struct SHADER_BUFFER *buffer);
|
||||
void shader_buffer_free(struct SHADER_BUFFER *buffer);
|
||||
|
||||
extern HRESULT shader_get_registers_used(
|
||||
IWineD3DBaseShader *iface,
|
||||
|
|
Loading…
Reference in New Issue