コード例 #1
0
ファイル: Image11.cpp プロジェクト: wolfviking0/webcl-webkit
gl::Error Image11::map(const gl::Context *context, D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map)
{
    // We must recover from the TextureStorage if necessary, even for D3D11_MAP_WRITE.
    ANGLE_TRY(recoverFromAssociatedStorage(context));

    const TextureHelper11 *stagingTexture = nullptr;
    unsigned int subresourceIndex  = 0;
    ANGLE_TRY(getStagingTexture(&stagingTexture, &subresourceIndex));

    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();

    ASSERT(stagingTexture && stagingTexture->valid());
    HRESULT result = deviceContext->Map(stagingTexture->get(), subresourceIndex, mapType, 0, map);

    if (FAILED(result))
    {
        // this can fail if the device is removed (from TDR)
        if (d3d11::isDeviceLostError(result))
        {
            mRenderer->notifyDeviceLost();
        }
        return gl::OutOfMemory() << "Failed to map staging texture, " << gl::FmtHR(result);
    }

    mDirty = true;

    return gl::NoError();
}
コード例 #2
0
ファイル: Image11.cpp プロジェクト: contoso-d/angle
gl::Error Image11::map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map)
{
    // We must recover from the TextureStorage if necessary, even for D3D11_MAP_WRITE.
    gl::Error error = recoverFromAssociatedStorage();
    if (error.isError())
    {
        return error;
    }

    ID3D11Resource *stagingTexture = NULL;
    unsigned int subresourceIndex = 0;
    error = getStagingTexture(&stagingTexture, &subresourceIndex);
    if (error.isError())
    {
        return error;
    }

    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();

    ASSERT(mStagingTexture);
    HRESULT result = deviceContext->Map(stagingTexture, subresourceIndex, mapType, 0, map);

    // this can fail if the device is removed (from TDR)
    if (d3d11::isDeviceLostError(result))
    {
        mRenderer->notifyDeviceLost();
    }
    else if (FAILED(result))
    {
        return gl::Error(GL_OUT_OF_MEMORY, "Failed to map staging texture, result: 0x%X.", result);
    }

    mDirty = true;

    return gl::Error(GL_NO_ERROR);
}