示例#1
0
文件: shader.c 项目: r6144/wine
HRESULT d3d10_vertex_shader_init(struct d3d10_vertex_shader *shader, struct d3d10_device *device,
                                 const void *byte_code, SIZE_T byte_code_length)
{
    struct d3d10_shader_info shader_info;
    HRESULT hr;

    shader->vtbl = &d3d10_vertex_shader_vtbl;
    shader->refcount = 1;

    shader_info.output_signature = &shader->output_signature;
    hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info);
    if (FAILED(hr))
    {
        ERR("Failed to extract shader, hr %#x.\n", hr);
        return hr;
    }

    hr = IWineD3DDevice_CreateVertexShader(device->wined3d_device, shader_info.shader_code,
                                           &shader->output_signature, shader, &d3d10_vertex_shader_wined3d_parent_ops, &shader->wined3d_shader);
    if (FAILED(hr))
    {
        WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
        shader_free_signature(&shader->output_signature);
        return hr;
    }

    return S_OK;
}
示例#2
0
文件: vertexshader.c 项目: devyn/wine
/* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
    HRESULT hrc = D3D_OK;
    IDirect3DVertexShader9Impl *object;

    /* Setup a stub object for now */
    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
    TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
    if (NULL == object) {
        FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
        return D3DERR_OUTOFVIDEOMEMORY;
    }

    object->ref = 1;
    object->lpVtbl = &Direct3DVertexShader9_Vtbl;
    EnterCriticalSection(&d3d9_cs);
    hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, NULL /* declaration */, pFunction, &object->wineD3DVertexShader, (IUnknown *)object);
    LeaveCriticalSection(&d3d9_cs);

    if (FAILED(hrc)) {

        /* free up object */
        FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
        HeapFree(GetProcessHeap(), 0, object);
    }else{
        IDirect3DDevice9Ex_AddRef(iface);
        object->parentDevice = iface;
        *ppShader = (IDirect3DVertexShader9 *)object;
        TRACE("(%p) : Created vertex shader %p\n", This, object);
    }

    TRACE("(%p) : returning %p\n", This, *ppShader);
    return hrc;
}
示例#3
0
HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
{
    HRESULT hr;

    shader->ref = 1;
    shader->lpVtbl = &Direct3DVertexShader9_Vtbl;

    wined3d_mutex_lock();
    hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code,
            NULL /* output signature */, &shader->wineD3DVertexShader,
            (IUnknown *)shader, &d3d9_vertexshader_wined3d_parent_ops);
    wined3d_mutex_unlock();
    if (FAILED(hr))
    {
        WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
        return hr;
    }

    shader->parentDevice = (IDirect3DDevice9Ex *)device;
    IDirect3DDevice9Ex_AddRef(shader->parentDevice);

    return D3D_OK;
}