optimize renderSamples

only render sample which has changed
This commit is contained in:
tildearrow 2023-09-08 01:19:48 -05:00
parent 6b6a8518ce
commit 624e45afa8
5 changed files with 45 additions and 43 deletions

View file

@ -396,13 +396,13 @@ int DivEngine::loadSampleROMs() {
return error;
}
void DivEngine::renderSamplesP() {
void DivEngine::renderSamplesP(int whichSample) {
BUSY_BEGIN;
renderSamples();
renderSamples(whichSample);
BUSY_END;
}
void DivEngine::renderSamples() {
void DivEngine::renderSamples(int whichSample) {
sPreview.sample=-1;
sPreview.pos=0;
sPreview.dir=false;
@ -418,8 +418,12 @@ void DivEngine::renderSamples() {
}
// step 1: render samples
for (int i=0; i<song.sampleLen; i++) {
song.sample[i]->render(formatMask);
if (whichSample==-1) {
for (int i=0; i<song.sampleLen; i++) {
song.sample[i]->render(formatMask);
}
} else if (whichSample>=0 && whichSample<song.sampleLen) {
song.sample[whichSample]->render(formatMask);
}
// step 2: render samples to dispatch