The VirtualProtect()
function in the Win32 API allows one to make memory pages read-only, write-only, executable-only, and a wide range of other settings.
I can see the security motivation, but if I had some memory I'd allocated, say on the heap, and I knew my application would only be reading from that memory, would setting the page to read-only improve access performance?
Likewise, does the same hold for setting it to write-only if I know the application will only be writing to that memory?
I ask, as I have a dim memory from my research into the Vulkan API, that marking certain memory objects, like attachments, as having certain access patterns, tells the driver to optimize that memory object and its layout.