Skip to content

Commit

Permalink
apps/d3d1[01]: More comprehensive map tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfonseca committed Aug 22, 2014
1 parent f052689 commit 8ebdc7a
Show file tree
Hide file tree
Showing 15 changed files with 719 additions and 109 deletions.
11 changes: 2 additions & 9 deletions apps/d3d10/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,12 @@ set (api d3d10)

set (targets
tri
map_no_overwrite
map_buffer
)

foreach (target ${targets})
add_executable (${api}_${target} ${target}.cpp)
set_target_properties (${api}_${target} PROPERTIES OUTPUT_NAME ${target})

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${target}.ref.txt)
add_app_test(
NAME ${api}_${target}
TARGET ${api}_${target}
REF ${target}.ref.txt
)
endif ()
endforeach (target)

add_app_tests ()
77 changes: 63 additions & 14 deletions apps/d3d10/map_no_overwrite.cpp → apps/d3d10/map_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ main(int argc, char *argv[])
{
HRESULT hr;

D3D10_USAGE Usage = D3D10_USAGE_DYNAMIC;
for (int i = 1; i < argc; ++i) {
const char *arg = argv[i];
if (strcmp(arg, "-dynamic") == 0) {
Usage = D3D10_USAGE_DYNAMIC;
} else if (strcmp(arg, "-staging") == 0) {
Usage = D3D10_USAGE_STAGING;
} else {
fprintf(stderr, "error: unknown arg %s\n", arg);
exit(1);
}
}

com_ptr<IDXGIFactory> pFactory;
hr = CreateDXGIFactory(IID_IDXGIFactory, (void**)&pFactory);
if (FAILED(hr)) {
Expand Down Expand Up @@ -76,35 +89,71 @@ main(int argc, char *argv[])
return 1;
}

UINT NumBuffers = 4;
UINT NumSegments = 8;
UINT SegmentSize = 512;

D3D10_BUFFER_DESC BufferDesc;
ZeroMemory(&BufferDesc, sizeof BufferDesc);
BufferDesc.Usage = D3D10_USAGE_DYNAMIC;
BufferDesc.ByteWidth = NumSegments * SegmentSize;
BufferDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
BufferDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
BufferDesc.MiscFlags = 0;

com_ptr<ID3D10Buffer> pVertexBuffer;
hr = pDevice->CreateBuffer(&BufferDesc, NULL, &pVertexBuffer);
if (FAILED(hr)) {
return 1;
BufferDesc.Usage = Usage;
if (Usage == D3D10_USAGE_STAGING) {
BufferDesc.BindFlags = 0;
} else {
BufferDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
}

for (UINT j = 0; j < NumSegments; ++j) {
D3D10_MAP MapType = j == 0 ? D3D10_MAP_WRITE_DISCARD : D3D10_MAP_WRITE_NO_OVERWRITE;
BYTE *pMap = NULL;
hr = pVertexBuffer->Map(MapType, 0, (void **)&pMap);
D3D10_MAP MapType = D3D10_MAP_WRITE;
for (UINT i = 0; i < NumBuffers; ++i) {
com_ptr<ID3D10Buffer> pVertexBuffer;
hr = pDevice->CreateBuffer(&BufferDesc, NULL, &pVertexBuffer);
if (FAILED(hr)) {
return 1;
}

if (Usage == D3D10_USAGE_DYNAMIC) {
MapType = D3D10_MAP_WRITE_DISCARD;
}

for (UINT j = 0; j < NumSegments; ++j) {
BYTE *pMap = NULL;
hr = pVertexBuffer->Map(MapType, 0, (void **)&pMap);
if (FAILED(hr)) {
return 1;
}

int c = (j % 255) + 1;
memset(pMap + j*SegmentSize, c, SegmentSize);

pVertexBuffer->Unmap();

if (Usage == D3D10_USAGE_DYNAMIC) {
MapType = D3D10_MAP_WRITE_NO_OVERWRITE;
}
}

pDevice->Flush();

D3D10_QUERY_DESC QueryDesc;
QueryDesc.Query = D3D10_QUERY_EVENT;
QueryDesc.MiscFlags = 0;
com_ptr<ID3D10Query> pQuery;
hr = pDevice->CreateQuery(&QueryDesc, &pQuery);
if (FAILED(hr)) {
return 1;
}

pQuery->End();

int c = (j % 255) + 1;
memset(pMap + j*SegmentSize, c, SegmentSize);
do {
hr = pQuery->GetData(NULL, 0, 0);
} while (hr == S_FALSE);
if (FAILED(hr)) {
return 1;
}

pVertexBuffer->Unmap();
}

return 0;
Expand Down
136 changes: 136 additions & 0 deletions apps/d3d10/map_buffer_no_overwrite.ref.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
//!map_buffer -dynamic
CreateDXGIFactory(riid = {Data1 = 2071029484, Data2 = 8647, Data3 = 17582, Data4 = {178, 26, 201, 174, 50, 26, 227, 105}}, ppFactory = &<pFactory>) = S_OK
IDXGIFactory::EnumAdapters(this = <pFactory>, Adapter = 0, ppAdapter = &<pAdapter>) = S_OK
D3D10CreateDevice(pAdapter = <pAdapter>, DriverType = D3D10_DRIVER_TYPE_HARDWARE, Software = NULL, Flags = <>, SDKVersion = 29, ppDevice = &<pDevice>) = S_OK

ID3D10Device::CreateBuffer(this = <pDevice>, pDesc = &{ByteWidth = 4096, Usage = D3D10_USAGE_DYNAMIC, BindFlags = D3D10_BIND_VERTEX_BUFFER, CPUAccessFlags = D3D10_CPU_ACCESS_WRITE, MiscFlags = 0x0}, pInitialData = NULL, ppBuffer = &<pVertexBuffer0>) = S_OK
ID3D10Buffer::Map(this = <pVertexBuffer0>, MapType = D3D10_MAP_WRITE_DISCARD, MapFlags = 0x0, ppData = &<pMap0>) = S_OK
memcpy(dest = <pMap0>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer0>)
ID3D10Buffer::Map(this = <pVertexBuffer0>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap0>) = S_OK
memcpy(dest = <pMap0>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer0>)
ID3D10Buffer::Map(this = <pVertexBuffer0>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap0>) = S_OK
memcpy(dest = <pMap0>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer0>)
ID3D10Buffer::Map(this = <pVertexBuffer0>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap0>) = S_OK
memcpy(dest = <pMap0>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer0>)
ID3D10Buffer::Map(this = <pVertexBuffer0>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap0>) = S_OK
memcpy(dest = <pMap0>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer0>)
ID3D10Buffer::Map(this = <pVertexBuffer0>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap0>) = S_OK
memcpy(dest = <pMap0>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer0>)
ID3D10Buffer::Map(this = <pVertexBuffer0>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap0>) = S_OK
memcpy(dest = <pMap0>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer0>)
ID3D10Buffer::Map(this = <pVertexBuffer0>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap0>) = S_OK
memcpy(dest = <pMap0>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer0>)
ID3D10Device::Flush(this = <pDevice>)
ID3D10Device::CreateQuery(this = <pDevice>, pQueryDesc = &{Query = D3D10_QUERY_EVENT, MiscFlags = 0x0}, ppQuery = &<pQuery0>) = S_OK
ID3D10Query::End(this = <pQuery0>)
ID3D10Query::GetData(this = <pQuery0>, pData = NULL, DataSize = 0, GetDataFlags = 0x0) = S_OK
ID3D10Query::Release(this = <pQuery0>) = 0
ID3D10Buffer::Release(this = <pVertexBuffer0>) = 0

ID3D10Device::CreateBuffer(this = <pDevice>, pDesc = &{ByteWidth = 4096, Usage = D3D10_USAGE_DYNAMIC, BindFlags = D3D10_BIND_VERTEX_BUFFER, CPUAccessFlags = D3D10_CPU_ACCESS_WRITE, MiscFlags = 0x0}, pInitialData = NULL, ppBuffer = &<pVertexBuffer1>) = S_OK
ID3D10Buffer::Map(this = <pVertexBuffer1>, MapType = D3D10_MAP_WRITE_DISCARD, MapFlags = 0x0, ppData = &<pMap1>) = S_OK
memcpy(dest = <pMap1>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer1>)
ID3D10Buffer::Map(this = <pVertexBuffer1>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap1>) = S_OK
memcpy(dest = <pMap1>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer1>)
ID3D10Buffer::Map(this = <pVertexBuffer1>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap1>) = S_OK
memcpy(dest = <pMap1>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer1>)
ID3D10Buffer::Map(this = <pVertexBuffer1>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap1>) = S_OK
memcpy(dest = <pMap1>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer1>)
ID3D10Buffer::Map(this = <pVertexBuffer1>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap1>) = S_OK
memcpy(dest = <pMap1>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer1>)
ID3D10Buffer::Map(this = <pVertexBuffer1>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap1>) = S_OK
memcpy(dest = <pMap1>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer1>)
ID3D10Buffer::Map(this = <pVertexBuffer1>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap1>) = S_OK
memcpy(dest = <pMap1>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer1>)
ID3D10Buffer::Map(this = <pVertexBuffer1>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap1>) = S_OK
memcpy(dest = <pMap1>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer1>)
ID3D10Device::Flush(this = <pDevice>)
ID3D10Device::CreateQuery(this = <pDevice>, pQueryDesc = &{Query = D3D10_QUERY_EVENT, MiscFlags = 0x0}, ppQuery = &<pQuery1>) = S_OK
ID3D10Query::End(this = <pQuery1>)
ID3D10Query::GetData(this = <pQuery1>, pData = NULL, DataSize = 0, GetDataFlags = 0x0) = S_OK
ID3D10Query::Release(this = <pQuery1>) = 0
ID3D10Buffer::Release(this = <pVertexBuffer1>) = 0

ID3D10Device::CreateBuffer(this = <pDevice>, pDesc = &{ByteWidth = 4096, Usage = D3D10_USAGE_DYNAMIC, BindFlags = D3D10_BIND_VERTEX_BUFFER, CPUAccessFlags = D3D10_CPU_ACCESS_WRITE, MiscFlags = 0x0}, pInitialData = NULL, ppBuffer = &<pVertexBuffer2>) = S_OK
ID3D10Buffer::Map(this = <pVertexBuffer2>, MapType = D3D10_MAP_WRITE_DISCARD, MapFlags = 0x0, ppData = &<pMap2>) = S_OK
memcpy(dest = <pMap2>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer2>)
ID3D10Buffer::Map(this = <pVertexBuffer2>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap2>) = S_OK
memcpy(dest = <pMap2>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer2>)
ID3D10Buffer::Map(this = <pVertexBuffer2>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap2>) = S_OK
memcpy(dest = <pMap2>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer2>)
ID3D10Buffer::Map(this = <pVertexBuffer2>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap2>) = S_OK
memcpy(dest = <pMap2>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer2>)
ID3D10Buffer::Map(this = <pVertexBuffer2>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap2>) = S_OK
memcpy(dest = <pMap2>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer2>)
ID3D10Buffer::Map(this = <pVertexBuffer2>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap2>) = S_OK
memcpy(dest = <pMap2>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer2>)
ID3D10Buffer::Map(this = <pVertexBuffer2>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap2>) = S_OK
memcpy(dest = <pMap2>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer2>)
ID3D10Buffer::Map(this = <pVertexBuffer2>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap2>) = S_OK
memcpy(dest = <pMap2>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer2>)
ID3D10Device::Flush(this = <pDevice>)
ID3D10Device::CreateQuery(this = <pDevice>, pQueryDesc = &{Query = D3D10_QUERY_EVENT, MiscFlags = 0x0}, ppQuery = &<pQuery2>) = S_OK
ID3D10Query::End(this = <pQuery2>)
ID3D10Query::GetData(this = <pQuery2>, pData = NULL, DataSize = 0, GetDataFlags = 0x0) = S_OK
ID3D10Query::Release(this = <pQuery2>) = 0
ID3D10Buffer::Release(this = <pVertexBuffer2>) = 0

ID3D10Device::CreateBuffer(this = <pDevice>, pDesc = &{ByteWidth = 4096, Usage = D3D10_USAGE_DYNAMIC, BindFlags = D3D10_BIND_VERTEX_BUFFER, CPUAccessFlags = D3D10_CPU_ACCESS_WRITE, MiscFlags = 0x0}, pInitialData = NULL, ppBuffer = &<pVertexBuffer3>) = S_OK
ID3D10Buffer::Map(this = <pVertexBuffer3>, MapType = D3D10_MAP_WRITE_DISCARD, MapFlags = 0x0, ppData = &<pMap3>) = S_OK
memcpy(dest = <pMap3>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer3>)
ID3D10Buffer::Map(this = <pVertexBuffer3>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap3>) = S_OK
memcpy(dest = <pMap3>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer3>)
ID3D10Buffer::Map(this = <pVertexBuffer3>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap3>) = S_OK
memcpy(dest = <pMap3>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer3>)
ID3D10Buffer::Map(this = <pVertexBuffer3>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap3>) = S_OK
memcpy(dest = <pMap3>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer3>)
ID3D10Buffer::Map(this = <pVertexBuffer3>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap3>) = S_OK
memcpy(dest = <pMap3>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer3>)
ID3D10Buffer::Map(this = <pVertexBuffer3>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap3>) = S_OK
memcpy(dest = <pMap3>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer3>)
ID3D10Buffer::Map(this = <pVertexBuffer3>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap3>) = S_OK
memcpy(dest = <pMap3>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer3>)
ID3D10Buffer::Map(this = <pVertexBuffer3>, MapType = D3D10_MAP_WRITE_NO_OVERWRITE, MapFlags = 0x0, ppData = &<pMap3>) = S_OK
memcpy(dest = <pMap3>, src = blob(4096), n = 4096)
ID3D10Buffer::Unmap(this = <pVertexBuffer3>)
ID3D10Device::Flush(this = <pDevice>)
ID3D10Device::CreateQuery(this = <pDevice>, pQueryDesc = &{Query = D3D10_QUERY_EVENT, MiscFlags = 0x0}, ppQuery = &<pQuery3>) = S_OK
ID3D10Query::End(this = <pQuery3>)
ID3D10Query::GetData(this = <pQuery3>, pData = NULL, DataSize = 0, GetDataFlags = 0x0) = S_OK
ID3D10Query::Release(this = <pQuery3>) = 0
ID3D10Buffer::Release(this = <pVertexBuffer3>) = 0

ID3D10Device::Release(this = <pDevice>) = 0
IDXGIAdapter::Release(this = <pAdapter>) = 0
IDXGIFactory::Release(this = <pFactory>) = 0
Loading

0 comments on commit 8ebdc7a

Please sign in to comment.