made an account to reply here..
if your desctop resolution isnt in the dafault available resolutions, (example, you created a 4:3 1400x1050 resolution using nvidias custom resolutions tool for an arcade cabinet.) mame will fail to render the window and will spit out a directx error.
if you absolutley need to make a custom resolution for your cabinet, edit the edid data your pc sees for your monitor so that resolution becomes a default resolution or preferably the native resolution.
the easiest way to do that is to use CRU (custom resoltion utility)
just had the same issue exactly as i described above. and thats how i fixed it..
The strange thing is, it worked fine when i set it up last week, but then we went on a long weekend trip so i powered the cabinet down.. when i came back mame had the above errors. (i knew i had the runtimes installed. but installed them again along with gpu drivers and other runtimes i knew i needed.
Finally i decided it had to be the resolution, and when i saw it wasnt available as an option in mame i figured out what the issue was.
so there ya go. hope that helps people, you dont need to reinstall your OS.