c++ - Mapping dynamic texture causing "Already Mapped Error" -
c++ - Mapping dynamic texture causing "Already Mapped Error" -
i starting using direct3d11 , trying create dynamic texture plan update new info several times second. issue every time update texture new data, error d3d debugger:
d3d11: error: id3d11devicecontext::map: resource mapped! [resource_manipulation error #2097213: resource_map_alreadymapped ]
which turns e_outofmemory error map phone call after running application while.
i creating texture this:
d3d11_texture2d_desc td; td.arraysize = 1; td.bindflags = d3d11_bind_shader_resource; td.cpuaccessflags = d3d11_cpu_access_write; td.format = dxgi_format_b8g8r8x8_unorm; td.height = height; td.width = width; td.miplevels = 1; td.miscflags = 0; td.sampledesc.count = 1; td.sampledesc.quality = 0; td.usage = d3d11_usage_dynamic; hr(m_device->createtexture2d(&td, 0, &texture));
and updating info this:
hr(m_devicecontext->map(texture, 0, d3d11_map_write_discard, 0, &mappedresource)); byte* mappeddata = reinterpret_cast<byte*>(mappedresource.pdata); for(uint = 0; < height; ++i) { memcpy(mappeddata, buffer,rowspan); mappeddata += mappedresource.rowpitch; buffer += rowspan; } m_devicecontext->unmap(texture, 0);
before create texture , map info it, have done in programme initialize direct3d devices. stumped on doing wrong. have been trying read much can on msdn nil has helped me figure out going wrong. according msdn, taking proper steps:
http://msdn.microsoft.com/en-us/library/ff476905(v=vs.85).aspx#dynamic
to fill dynamic texture (one created d3d11_usage_dynamic): pointer texture memory passing in d3d11_map_write_discard when calling id3d11devicecontext::map. write info memory. phone call id3d11devicecontext::unmap when finished writing data.
i have filling out texture description correctly too.
could issue stemming initialization of d3d devices? misusing map function? did not provide plenty background information? ideas on whats going on?
additional information: same "resource mapped" error when seek map info constant buffer vertex shader. also, tested out on different computer , got same mapping problems.
update: downloaded tutorial code d3d11 , took texture creation , mapping code , plopped in right after tutorial code finished initializing d3d. wanted see if mapping error. expected, did not "resource mapped" error. furthermore, when re-create d3d initialization code tutorial , replace mine, still resource mapped error confuses me farther because before initializing d3d create window.
its funny how when start asking questions stuck on, becomes easier find problem haha.
i figured out issue was. hr macro surrounding map phone call with.
#define hr(x) { hresult hr = (x); if(failed(x)) { dxtrace(__file__, (dword)__line__, hr, l#x, true); } }
i have no thought why root of problem, know how macro have issue map call.
c++ directx texture2d directx-11
Comments
Post a Comment