Home Dashboard Directory Help
Search

Unable to access a writable texture in direct3d by nigelwright7557


Status: 

Closed


1
0
Sign in
to vote
Type: Bug
ID: 800834
Opened: 9/15/2013 2:46:20 PM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

I found the problem, it needs enclosing in a FAIL statement.
-------------------------------------------------------------------

I get the following error:
Error    4    error C2664: 'ID3D11Device::CreateTexture2D' : cannot convert parameter 2 from 'Renderer::Render::D3D11_SUBRESOURCE_DATA *' to 'const D3D11_SUBRESOURCE_DATA *'    c:\simplesample\c++\renderer.cpp    316    1    SimpleSample

Erro is relevant to last line of code with &data.

With this code from simplesample (MS example)


void Renderer::Render()
{
/*    m_d3dContext->ClearRenderTargetView(
        m_renderTargetView.Get(),
        Colors::MidnightBlue
        );
        */
    m_d3dContext->ClearDepthStencilView(
        m_depthStencilView.Get(),
        D3D11_CLEAR_DEPTH,
        1.0f,
        0
        );

    m_d3dContext->OMSetRenderTargets(
        1,
        m_renderTargetView.GetAddressOf(),
        m_depthStencilView.Get()
        );

    // Draw procedurally generated dynamic grid
    const XMVECTORF32 xaxis = { 20.f, 0.f, 0.f };
    const XMVECTORF32 yaxis = { 0.f, 0.f, 20.f };
//    DrawGrid( xaxis, yaxis, g_XMZero, 20, 20, Colors::Gray );
    


    /////////////////////////////////////////////
    UINT fred;
    m_d3dDevice->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 16, &fred);

    D3D11_TEXTURE2D_DESC desc;
    ZeroMemory(&desc, sizeof(D3D11_TEXTURE2D_DESC));
    desc.ArraySize = 1;
    desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
    desc.CPUAccessFlags = 0;
    desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    desc.MipLevels = 1;
    desc.MiscFlags = 0;
    desc.SampleDesc.Count = 4;
    desc.SampleDesc.Quality = fred;
    desc.Usage = D3D11_USAGE_DEFAULT;
    desc.Width = 1024;
    desc.Height = 1024;


    ID3D11Texture2D *pTexture = NULL;


    typedef struct D3D11_SUBRESOURCE_DATA {
        const void *pSysMem;
        UINT     SysMemPitch;
        UINT     SysMemSlicePitch;
    } D3D11_SUBRESOURCE_DATA;

    m_d3dDevice->CreateTexture2D(&desc, NULL, &pTexture);

    D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDescription;
    ZeroMemory(&renderTargetViewDescription, sizeof(renderTargetViewDescription));
    renderTargetViewDescription.Format = desc.Format;

    renderTargetViewDescription.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;

        DX::ThrowIfFailed(
    m_d3dDevice->CreateRenderTargetView(
    pTexture,
        &renderTargetViewDescription,
        &m_renderTargetView
        )
        );
    /////////////////////////////////////////////////////////////////////////////////////
    byte buffer[10 * 10 * sizeof(int)];
    int pixelSize = sizeof(int);//pixel size. Each pixels are represented by a int 32bits.
    D3D11_SUBRESOURCE_DATA data;
    data.pSysMem = buffer; //pixel buffer
    data.SysMemPitch = pixelSize *desc.Width;// line size in byte
    data.SysMemSlicePitch =    pixelSize *desc.Width*desc.Height ;// total buffer size in byte



    m_d3dDevice->CreateTexture2D(&desc, &data, &pTexture);
    



    }

Details
Sign in to post a comment.
Posted by Microsoft on 9/23/2013 at 4:37 PM
Hi,
    Thanks for reporting the issue. The error is by design. You are passing a variable of local class type to the API. However, the API expects the type defined in the global scope with the same name.
    It is similar to the following example:

struct S {
    int i;
};

void f(const S *);

void g()
{
    struct S {
        int i;
    };

    S s;
    f(&s); // cannot convert parameter 1 from 'g::S *' to 'const S *'
}
Posted by Microsoft on 9/19/2013 at 8:41 PM
Hello again. We wanted to give you a quick reminder that to efficiently investigate and reproduce your issue, we need you submit the additional information we requested. We look forward to hearing from you with this information.
Posted by Microsoft on 9/17/2013 at 4:59 AM
Hello,

Thank you for submitting feedback on Visual Studio and .NET Framework. Could you please tell us whether you run the code with VS2013RC on Win8.1rtm? Because the VS2013RC couldn't install on Win8.1preview. In order to efficiently investigate and reproduce this issue, could you please give us a demo project so that we can conduct further research?

We look forward to hearing from you with this information.
Posted by Microsoft on 9/15/2013 at 2:53 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.