Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with Dynamic usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(
  _Resource,
  0,
  SharpDX.Direct3D11.MapMode.Write,
  SharpDX.Direct3D11.MapFlags.None,
  out stream
);

I see from this questionthis question that it is supported. The MSDN docs and this other questionthis other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() (though it does for the D3D 10 equivalent).

If I call the above with MapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in Direct3D 11 or am I looking in the wrong place? Is the MapSubresource() method unsuitable or am I using it wrong?

EDIT: I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question!

I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with Dynamic usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(
  _Resource,
  0,
  SharpDX.Direct3D11.MapMode.Write,
  SharpDX.Direct3D11.MapFlags.None,
  out stream
);

I see from this question that it is supported. The MSDN docs and this other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() (though it does for the D3D 10 equivalent).

If I call the above with MapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in Direct3D 11 or am I looking in the wrong place? Is the MapSubresource() method unsuitable or am I using it wrong?

EDIT: I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question!

I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with Dynamic usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(
  _Resource,
  0,
  SharpDX.Direct3D11.MapMode.Write,
  SharpDX.Direct3D11.MapFlags.None,
  out stream
);

I see from this question that it is supported. The MSDN docs and this other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() (though it does for the D3D 10 equivalent).

If I call the above with MapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in Direct3D 11 or am I looking in the wrong place? Is the MapSubresource() method unsuitable or am I using it wrong?

EDIT: I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question!

added 51 characters in body; edited tags; edited title
Source Link
user1430
user1430

Updating resources in SharpDX - why Why can I not map a dynamic texture in D3D?

I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with Dynamic usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(
  _Resource,
  0,
  SharpDX.Direct3D11.MapMode.Write,
  SharpDX.Direct3D11.MapFlags.None,
  out stream 
);

I see from this question that it is supported. The MSDN docs and this other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() Map() (though it does for the DX10D3D 10 equivalent).

If I call the above with MapMode.WriteDiscardMapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in DirectX11Direct3D 11 or am I looking in the wrong place? Is the MapSubresource() method unsuitable or am I using it wrong?

EDIT: I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question! I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question!

Updating resources in SharpDX - why can I not map a dynamic texture?

I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with Dynamic usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(_Resource, 0, SharpDX.Direct3D11.MapMode.Write, SharpDX.Direct3D11.MapFlags.None, out stream);

I see from this question that it is supported. The MSDN docs and this other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() (though it does for the DX10 equivalent).

If I call the above with MapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in DirectX11 or am I looking in the wrong place? Is the MapSubresource() method unsuitable or am I using it wrong?

EDIT: I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question!

Why can I not map a dynamic texture in D3D?

I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with Dynamic usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(
  _Resource,
  0,
  SharpDX.Direct3D11.MapMode.Write,
  SharpDX.Direct3D11.MapFlags.None,
  out stream 
);

I see from this question that it is supported. The MSDN docs and this other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() (though it does for the D3D 10 equivalent).

If I call the above with MapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in Direct3D 11 or am I looking in the wrong place? Is the MapSubresource() method unsuitable or am I using it wrong?

EDIT: I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question!

added 172 characters in body
Source Link
user5399
user5399

I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with DefaultDynamic usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(_Resource, 0, SharpDX.Direct3D11.MapMode.Write, SharpDX.Direct3D11.MapFlags.None, out stream);

I see from this question that it is supported. The MSDN docs and this other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() (though it does for the DX10 equivalent).

If I call the above with MapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in DirectX11 or am I looking in the wrong place? Is the MapSubresource() method unsuitable or am I using it wrong?

EDIT: I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question!

I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with Default usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(_Resource, 0, SharpDX.Direct3D11.MapMode.Write, SharpDX.Direct3D11.MapFlags.None, out stream);

I see from this question that it is supported. The MSDN docs and this other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() (though it does for the DX10 equivalent).

If I call the above with MapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in DirectX11 or am I looking in the wrong place? Is the MapSubresource() method unsuitable or am I using it wrong?

I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with Dynamic usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(_Resource, 0, SharpDX.Direct3D11.MapMode.Write, SharpDX.Direct3D11.MapFlags.None, out stream);

I see from this question that it is supported. The MSDN docs and this other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() (though it does for the DX10 equivalent).

If I call the above with MapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in DirectX11 or am I looking in the wrong place? Is the MapSubresource() method unsuitable or am I using it wrong?

EDIT: I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question!

Source Link
user5399
user5399
Loading