src/render/direct3d11/SDL_render_d3d11.cpp
changeset 8550 321f0992541c
parent 8548 db8a89a4e633
child 8553 199f6c870823
equal deleted inserted replaced
8549:0eee3a6f8c75 8550:321f0992541c
  1382     return 0;
  1382     return 0;
  1383 }
  1383 }
  1384 
  1384 
  1385 static int
  1385 static int
  1386 D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
  1386 D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
  1387                          const void * vertexData, unsigned int dataSizeInBytes)
  1387                          const void * vertexData, size_t dataSizeInBytes)
  1388 {
  1388 {
  1389     D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
  1389     D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
  1390     HRESULT result = S_OK;
  1390     HRESULT result = S_OK;
  1391     D3D11_BUFFER_DESC vertexBufferDesc;
  1391     D3D11_BUFFER_DESC vertexBufferDesc;
  1392 
  1392 
  1395     } else {
  1395     } else {
  1396         memset(&vertexBufferDesc, 0, sizeof(vertexBufferDesc));
  1396         memset(&vertexBufferDesc, 0, sizeof(vertexBufferDesc));
  1397     }
  1397     }
  1398 
  1398 
  1399     if (vertexBufferDesc.ByteWidth >= dataSizeInBytes) {
  1399     if (vertexBufferDesc.ByteWidth >= dataSizeInBytes) {
  1400         rendererData->d3dContext->UpdateSubresource(rendererData->vertexBuffer.Get(), 0, NULL, vertexData, dataSizeInBytes, 0);
  1400         D3D11_MAPPED_SUBRESOURCE mappedResource;
       
  1401         ZeroMemory(&mappedResource, sizeof(D3D11_MAPPED_SUBRESOURCE));
       
  1402         result = rendererData->d3dContext->Map(rendererData->vertexBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
       
  1403         if (FAILED(result)) {
       
  1404             WIN_SetErrorFromHRESULT(__FUNCTION__, result);
       
  1405             return -1;
       
  1406         }
       
  1407         memcpy(mappedResource.pData, vertexData, dataSizeInBytes);
       
  1408         rendererData->d3dContext->Unmap(rendererData->vertexBuffer.Get(), 0);
  1401     } else {
  1409     } else {
  1402         vertexBufferDesc.ByteWidth = dataSizeInBytes;
  1410         vertexBufferDesc.ByteWidth = dataSizeInBytes;
       
  1411         vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
  1403         vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
  1412         vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
       
  1413         vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
  1404 
  1414 
  1405         D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
  1415         D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
  1406         vertexBufferData.pSysMem = vertexData;
  1416         vertexBufferData.pSysMem = vertexData;
  1407         vertexBufferData.SysMemPitch = 0;
  1417         vertexBufferData.SysMemPitch = 0;
  1408         vertexBufferData.SysMemSlicePitch = 0;
  1418         vertexBufferData.SysMemSlicePitch = 0;