コード例 #1
0
ファイル: brush.c プロジェクト: DusteDdk/wine-multimedia
void d2d_brush_bind_resources(struct d2d_brush *brush, ID3D10Device *device)
{
    if (brush->type == D2D_BRUSH_TYPE_BITMAP)
    {
        ID3D10Device_PSSetShaderResources(device, 0, 1, &brush->u.bitmap.bitmap->view);
        ID3D10Device_PSSetSamplers(device, 0, 1, &brush->u.bitmap.sampler_state);
    }
}
コード例 #2
0
ファイル: d3dx10_43_main.c プロジェクト: AmesianX/wine
HRESULT WINAPI D3DX10UnsetAllDeviceObjects(ID3D10Device *device)
{
    static ID3D10ShaderResourceView * const views[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
    static ID3D10RenderTargetView * const target_views[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT];
    static ID3D10SamplerState * const sampler_states[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT];
    static ID3D10Buffer * const buffers[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
    static const unsigned int so_offsets[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] =
            {~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u};
    static const unsigned int strides[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
    static const unsigned int offsets[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
    static const float blend_factors[4];

    TRACE("device %p.\n", device);

    if (!device)
        return E_INVALIDARG;

    ID3D10Device_VSSetConstantBuffers(device, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, buffers);
    ID3D10Device_PSSetConstantBuffers(device, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, buffers);
    ID3D10Device_GSSetConstantBuffers(device, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, buffers);

    ID3D10Device_VSSetSamplers(device, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, sampler_states);
    ID3D10Device_PSSetSamplers(device, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, sampler_states);
    ID3D10Device_GSSetSamplers(device, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, sampler_states);

    ID3D10Device_VSSetShaderResources(device, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, views);
    ID3D10Device_PSSetShaderResources(device, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, views);
    ID3D10Device_GSSetShaderResources(device, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, views);

    ID3D10Device_VSSetShader(device, NULL);
    ID3D10Device_PSSetShader(device, NULL);
    ID3D10Device_GSSetShader(device, NULL);

    ID3D10Device_OMSetRenderTargets(device, D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT, target_views, NULL);

    ID3D10Device_IASetIndexBuffer(device, NULL, DXGI_FORMAT_R32_UINT, 0);
    ID3D10Device_IASetInputLayout(device, NULL);
    ID3D10Device_IASetVertexBuffers(device, 0, D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, buffers, strides, offsets);

    ID3D10Device_SOSetTargets(device, D3D10_SO_BUFFER_SLOT_COUNT, buffers, so_offsets);

    ID3D10Device_OMSetBlendState(device, NULL, blend_factors, 0);
    ID3D10Device_OMSetDepthStencilState(device, NULL, 0);

    ID3D10Device_RSSetState(device, NULL);

    ID3D10Device_SetPredication(device, NULL, FALSE);

    return S_OK;
}
コード例 #3
0
ファイル: brush.c プロジェクト: YongHaoWu/wine-hub
void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_d3d_render_target *render_target,
        enum d2d_shape_type shape_type)
{
    static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
    ID3D10Device *device = render_target->device;
    ID3D10PixelShader *ps;
    HRESULT hr;

    ID3D10Device_OMSetBlendState(device, render_target->bs, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
    if (!(ps = render_target->shape_resources[shape_type].ps[brush->type]))
        FIXME("No pixel shader for shape type %#x and brush type %#x.\n", shape_type, brush->type);
    ID3D10Device_PSSetShader(device, ps);

    if (brush->type == D2D_BRUSH_TYPE_BITMAP)
    {
        ID3D10Device_PSSetShaderResources(device, 0, 1, &brush->u.bitmap.bitmap->view);
        if (!brush->u.bitmap.sampler_state)
        {
            D3D10_SAMPLER_DESC sampler_desc;

            if (brush->u.bitmap.interpolation_mode == D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR)
                sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT;
            else
                sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
            sampler_desc.AddressU = texture_address_mode_from_extend_mode(brush->u.bitmap.extend_mode_x);
            sampler_desc.AddressV = texture_address_mode_from_extend_mode(brush->u.bitmap.extend_mode_y);
            sampler_desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
            sampler_desc.MipLODBias = 0.0f;
            sampler_desc.MaxAnisotropy = 0;
            sampler_desc.ComparisonFunc = D3D10_COMPARISON_NEVER;
            sampler_desc.BorderColor[0] = 0.0f;
            sampler_desc.BorderColor[1] = 0.0f;
            sampler_desc.BorderColor[2] = 0.0f;
            sampler_desc.BorderColor[3] = 0.0f;
            sampler_desc.MinLOD = 0.0f;
            sampler_desc.MaxLOD = 0.0f;

            if (FAILED(hr = ID3D10Device_CreateSamplerState(device,
                    &sampler_desc, &brush->u.bitmap.sampler_state)))
                ERR("Failed to create sampler state, hr %#x.\n", hr);
        }
        ID3D10Device_PSSetSamplers(device, 0, 1, &brush->u.bitmap.sampler_state);
    }
    else if (brush->type != D2D_BRUSH_TYPE_SOLID)
    {
        FIXME("Unhandled brush type %#x.\n", brush->type);
    }
}