Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. buffer size: 1922793
  2.  
  3. AL_MAP_WRITE_BIT_SOFT al_callac in LoadData:
  4. time: 0.001339
  5. time: 0.001617
  6. time: 0.001432
  7. time: 0.001500
  8. time: 0.001506
  9. time: 0.001463
  10. time: 0.001530
  11. time: 0.001548
  12. time: 0.001493
  13. time: 0.001633
  14.  
  15.  
  16. AL_MAP_WRITE_BIT_SOFT, al_malloc in loadData
  17. time: 0.001363
  18. time: 0.001500
  19. time: 0.001330
  20. time: 0.001467
  21. time: 0.001407
  22. time: 0.001342
  23. time: 0.001315
  24. time: 0.001465
  25. time: 0.001292
  26. time: 0.001459
  27. time: 0.001332
  28.  
  29.  
  30. AL_MAP_WRITE_BIT_SOFT | AL_MAP_READ_BIT_SOFT, al_malloc in loadData
  31. (eg. no memset on alBuffer data)
  32. time: 0.001097
  33. time: 0.000937
  34. time: 0.001005
  35. time: 0.000942
  36. time: 0.000984
  37. time: 0.001031
  38. time: 0.000946
  39. time: 0.000953
  40. time: 0.000939
  41. time: 0.001106
  42.  
  43.  
  44. // I still initialized the unreachable memory
  45. // but that's like 15 bytes max
  46. // was 7 in this test
  47. alBuffer.c: 1090
  48. - newsize = (newsize+15) & ~0xf;
  49. - if(newsize != ALBuf->BytesAlloc)
  50. - {
  51. - void *temp = al_calloc(16, (size_t)newsize);
  52. - if(!temp && newsize)
  53. - {
  54. - WriteUnlock(&ALBuf->lock);
  55. - return AL_OUT_OF_MEMORY;
  56. - }
  57. - al_free(ALBuf->data);
  58. - ALBuf->data = temp;
  59. - ALBuf->BytesAlloc = (ALuint)newsize;
  60. - }
  61.  
  62. + const ALuint64 paddedNewSize = (newsize+15) & ~0xf;
  63. + if(paddedNewSize != ALBuf->BytesAlloc)
  64. + {
  65. + void *temp = al_malloc(16, (size_t)paddedNewSize);
  66. + if(!temp && paddedNewSize)
  67. + {
  68. + WriteUnlock(&ALBuf->lock);
  69. + return AL_OUT_OF_MEMORY;
  70. + }
  71. +
  72. + memset(temp + newsize, 0, paddedNewSize - newsize);
  73. +
  74. + al_free(ALBuf->data);
  75. + ALBuf->data = temp;
  76. + ALBuf->BytesAlloc = (ALuint)paddedNewSize;
  77. + }
  78.  
  79. btw, if(newsize != ALBuf->BytesAlloc) returns false in the original
  80. you will get buffer with its old memory, which kind of invalidates
  81. the idea of getting zeroed memory.
  82.  
  83.  
  84. suggestion
  85. add AL_NO_MEMORY_INIT_BIT_SOFT, that will ensure, that no memset is
  86. performed on the alBuffer memory.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement