<p>I have found the following from this link
<a href="https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_mapped_subresource" rel="nofollow noreferrer">enter link description here</a></p>

<blockquote>
  <p>pData</p>
  
  <p>Type: void*</p>
  
  <p>Pointer to the data. When ID3D11DeviceContext::Map provides the
  pointer, the runtime ensures that the pointer has a specific
  alignment, depending on the following feature levels:</p>
  
  <p>For D3D_FEATURE_LEVEL_10_0 and higher, the pointer is aligned to 16
  bytes. For lower than D3D_FEATURE_LEVEL_10_0, the pointer is aligned
  to 4 bytes.</p>
</blockquote>

<p>Would someone please explain if I can reinterpret cast the void pointer into OLE_COLOR* or not?</p>

CC BY-SA 4.0
2020-02-09T07:28:09.053Z
What's OLD_HANDLE ?
PaulHK
CC BY-SA 4.0
2020-02-09T08:44:49.940Z
Sorry it should be OLE_COLOR*. I edited.
Tajuddin Khandaker
CC BY-SA 4.0
2020-02-10T02:31:06.117Z
That should be fine. You need to take care of memory alignment. This should be fine for pointers allocated via 'new' or other memory allocators, but be careful passing subscripts (e.g.  the 2nd element of an array, that may not be aligned to 16 bytes like the [0]th element)
PaulHK
<c++><directx11>
void* D3D11_MAPPED_SUBRESOURCE::pData to OLE_COLOR* possible?
Tajuddin Khandaker
# void* D3D11_MAPPED_SUBRESOURCE::pData to OLE_COLOR* possible?

(Asked by: username_0 on 2020-01-29)

I have found the following from this link
[enter link description here](https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_mapped_subresource)

> pData
>
> Type: void\*
>
> Pointer to the data. When ID3D11DeviceContext::Map provides the
> pointer, the runtime ensures that the pointer has a specific
> alignment, depending on the following feature levels:
>
> For D3D\_FEATURE\_LEVEL\_10\_0 and higher, the pointer is aligned to 16
> bytes. For lower than D3D\_FEATURE\_LEVEL\_10\_0, the pointer is aligned
> to 4 bytes.

Would someone please explain if I can reinterpret cast the void pointer into OLE\_COLOR\* or not?

**Tags:** c++, directx11

> **Comments:**
> **username_1**: What's OLD_HANDLE ?  
> **username_0**: Sorry it should be OLE_COLOR*. I edited.  
> **username_1**: That should be fine. You need to take care of memory alignment. This should be fine for pointers allocated via 'new' or other memory allocators, but be careful passing subscripts (e.g.  the 2nd element of an array, that may not be aligned to 16 bytes like the [0]th element)  

---

## 0 answers

